MCPcopy
hub / github.com/graphql/graphql-js / validateSchema

Function validateSchema

src/type/validate.ts:94–116  ·  view source on GitHub ↗
(
  schema: GraphQLSchema,
)

Source from the content-addressed store, hash-verified

92 * ```
93 */
94export function validateSchema(
95 schema: GraphQLSchema,
96): ReadonlyArray<GraphQLError> {
97 // First check to ensure the provided value is in fact a GraphQLSchema.
98 assertSchema(schema);
99
100 // If this Schema has already been validated, return the previous results.
101 if (schema.__validationErrors) {
102 return schema.__validationErrors;
103 }
104
105 // Validate the schema, producing a list of errors.
106 const context = new SchemaValidationContext(schema);
107 validateRootTypes(context);
108 validateDirectives(context);
109 validateTypes(context);
110
111 // Persist the results of validation before returning to ensure validation
112 // does not run multiple times for this schema.
113 const errors = context.getErrors();
114 schema.__validationErrors = errors;
115 return errors;
116}
117
118/**
119 * Utility function which asserts a schema is valid by throwing an error if

Callers 7

graphqlImplFunction · 0.90
validation-test.tsFile · 0.90
schema-test.tsFile · 0.90
assertValidSchemaFunction · 0.85

Calls 5

getErrorsMethod · 0.95
assertSchemaFunction · 0.90
validateRootTypesFunction · 0.85
validateDirectivesFunction · 0.85
validateTypesFunction · 0.85

Tested by

no test coverage detected