UNPKG

@theguild/federation-composition

Version:

Open Source Composition library for Apollo Federation

11 lines (10 loc) 484 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); }