Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function loadSchema(schemaPath: string): GraphQLSchema {
if (!fs.existsSync(schemaPath)) {
throw new ToolError(`Cannot find GraphQL schema file: ${schemaPath}`);
}
const schemaData = require(schemaPath);
if (!schemaData.data && !schemaData.__schema) {
throw new ToolError(
"GraphQL schema file should contain a valid GraphQL introspection query result"
);
}
return buildClientSchema(schemaData.data ? schemaData.data : schemaData);
}
export function loadSchema(schemaPath: string): GraphQLSchema {
if (!fs.existsSync(schemaPath)) {
throw new ToolError(`Cannot find GraphQL schema file: ${schemaPath}`);
}
const schemaData = require(schemaPath);
if (!schemaData.data && !schemaData.__schema) {
throw new ToolError(
"GraphQL schema file should contain a valid GraphQL introspection query result"
);
}
return buildClientSchema(schemaData.data ? schemaData.data : schemaData);
}