validateSDL function
List<GraphQLError>
validateSDL(
- DocumentNode document, {
- GraphQLSchema? schemaToExtend,
- List<
SDLValidationRule> rules = specifiedSDLRules,
Executes GraphQL schema validations for the given document
with an optional base schemaToExtend
.
If schemaToExtend
is non null, document
will be interpreted
as a schema extension.
Implementation
List<GraphQLError> validateSDL(
DocumentNode document, {
GraphQLSchema? schemaToExtend,
List<SDLValidationRule> rules = specifiedSDLRules,
}) {
final errors = <GraphQLError>[];
final ctx = SDLValidationCtx(
schema: schemaToExtend,
document: document,
onError: errors.add,
);
final visitor = ParallelVisitor(
visitors: rules.map((e) => e(ctx)).toList(),
onAccept: (obj) {
if (obj is List<GraphQLError>) {
errors.addAll(obj);
}
},
);
document.accept(visitor);
return errors;
}