Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!addToSchema) {
return schema;
}
schemaChanged = true;
return mergeSchemas([schema, addToSchema]);
}, options.schema);
const federationInConfig = pickFlag('federation', options.config);
const isFederation = prioritize(federationInConfig, false);
if (isFederation) {
schemaChanged = true;
schema = turnExtensionsIntoObjectTypes(mergeSchemas([schema, federationSpec]));
}
if (schemaChanged) {
options.schemaAst = buildASTSchema(schema, {
assumeValidSDL: isFederation,
});
}
const skipDocumentValidation = typeof options.config === 'object' && !Array.isArray(options.config) && options.config.skipDocumentsValidation;
if (options.schemaAst && documents.length > 0 && !skipDocumentValidation) {
const extraFragments = options.config && (options.config as any)['externalFragments'] ? (options.config as any)['externalFragments'] : [];
const errors = await validateGraphQlDocuments(options.schemaAst, [
...documents.map(({ filePath, content }) => ({ location: filePath, document: content })),
...extraFragments.map((f: any) => ({ location: f.importFrom, document: { kind: Kind.DOCUMENT, definitions: [f.node] } })),
]);