use of graphql.language.Definition in project graphql-java by graphql-java.
the class NoFragmentCycles method prepareFragmentMap.
private void prepareFragmentMap() {
List<Definition> definitions = getValidationContext().getDocument().getDefinitions();
for (Definition definition : definitions) {
if (definition instanceof FragmentDefinition) {
FragmentDefinition fragmentDefinition = (FragmentDefinition) definition;
fragmentSpreads.put(fragmentDefinition.getName(), gatherSpreads(fragmentDefinition));
}
}
}
use of graphql.language.Definition in project graphql-java by graphql-java.
the class ValidationContext method buildFragmentMap.
private void buildFragmentMap() {
for (Definition definition : document.getDefinitions()) {
if (!(definition instanceof FragmentDefinition))
continue;
FragmentDefinition fragmentDefinition = (FragmentDefinition) definition;
fragmentDefinitionMap.put(fragmentDefinition.getName(), fragmentDefinition);
}
}
use of graphql.language.Definition in project graphql-java by graphql-java.
the class SchemaParser method buildRegistry.
/**
* special method to build directly a TypeDefinitionRegistry from a Document
* useful for Introspection => IDL (Document) => TypeDefinitionRegistry
*
* @param document containing type definitions
*
* @return the TypeDefinitionRegistry containing all type definitions from the document
*
* @throws SchemaProblem if an error occurs
*/
public TypeDefinitionRegistry buildRegistry(Document document) {
List<GraphQLError> errors = new ArrayList<>();
TypeDefinitionRegistry typeRegistry = new TypeDefinitionRegistry();
List<Definition> definitions = document.getDefinitions();
for (Definition definition : definitions) {
typeRegistry.add(definition).ifPresent(errors::add);
}
if (errors.size() > 0) {
throw new SchemaProblem(errors);
} else {
return typeRegistry;
}
}
Aggregations