UNPKG

@theguild/federation-composition

Version:
11 lines (10 loc) 485 B
import { federationDirectives, federationEnums, federationScalars, } from './transform-supergraph-to-public-schema.js'; const supergraphSpecDetectionRegex = new RegExp(Array.from(federationScalars) .concat(Array.from(federationEnums)) .map(name => [`\\[${name}`, `\\s${name}`]) .flat(2) .concat(Array.from(federationDirectives).map(name => `@${name}`)) .join('|')); export function containsSupergraphSpec(sdl) { return supergraphSpecDetectionRegex.test(sdl); }