use of graphql.language.NamedNode in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method onUnion.
public GraphQLUnionType onUnion(GraphQLUnionType element, Parameters params) {
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(element.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(element);
Parameters newParams = params.newParams(nodeParentTree, elementParentTree);
return wireDirectives(params, element, element.getDirectives(), element.getAppliedDirectives(), (outputElement, directives, appliedDirectives, registeredDirective) -> new SchemaDirectiveWiringEnvironmentImpl<>(outputElement, directives, appliedDirectives, registeredDirective, newParams), SchemaDirectiveWiring::onUnion);
}
use of graphql.language.NamedNode in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method wireArguments.
private List<GraphQLArgument> wireArguments(GraphQLFieldDefinition fieldDefinition, GraphQLFieldsContainer fieldsContainer, NamedNode<?> fieldsContainerNode, Parameters params, GraphQLFieldDefinition field) {
return map(field.getArguments(), argument -> {
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(fieldsContainerNode, field.getDefinition(), argument.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(fieldsContainer, field, argument);
Parameters argParams = params.newParams(fieldDefinition, fieldsContainer, nodeParentTree, elementParentTree);
return onArgument(argument, argParams);
});
}
use of graphql.language.NamedNode in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method wireFields.
private List<GraphQLFieldDefinition> wireFields(GraphQLFieldsContainer fieldsContainer, NamedNode<?> fieldsContainerNode, Parameters params) {
return map(fieldsContainer.getFieldDefinitions(), fieldDefinition -> {
// and for each argument in the fieldDefinition run the wiring for them - and note that they can change
List<GraphQLArgument> startingArgs = fieldDefinition.getArguments();
List<GraphQLArgument> newArgs = wireArguments(fieldDefinition, fieldsContainer, fieldsContainerNode, params, fieldDefinition);
if (isNotTheSameObjects(startingArgs, newArgs)) {
// they may have changed the arguments to the fieldDefinition so reflect that
fieldDefinition = fieldDefinition.transform(builder -> builder.clearArguments().arguments(newArgs));
}
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(fieldsContainerNode, fieldDefinition.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(fieldsContainer, fieldDefinition);
Parameters fieldParams = params.newParams(fieldDefinition, fieldsContainer, nodeParentTree, elementParentTree);
// now for each fieldDefinition run the new wiring and capture the results
return onField(fieldDefinition, fieldParams);
});
}
use of graphql.language.NamedNode in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method onEnum.
public GraphQLEnumType onEnum(final GraphQLEnumType enumType, Parameters params) {
List<GraphQLEnumValueDefinition> startingEnumValues = enumType.getValues();
List<GraphQLEnumValueDefinition> newEnumValues = map(startingEnumValues, enumValueDefinition -> {
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(enumType.getDefinition(), enumValueDefinition.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(enumType, enumValueDefinition);
Parameters fieldParams = params.newParams(nodeParentTree, elementParentTree);
// now for each field run the new wiring and capture the results
return onEnumValue(enumValueDefinition, fieldParams);
});
GraphQLEnumType newEnumType = enumType;
if (isNotTheSameObjects(startingEnumValues, newEnumValues)) {
newEnumType = enumType.transform(builder -> builder.clearValues().values(newEnumValues));
}
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(newEnumType.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(newEnumType);
Parameters newParams = params.newParams(nodeParentTree, elementParentTree);
return wireDirectives(params, newEnumType, newEnumType.getDirectives(), newEnumType.getAppliedDirectives(), (outputElement, directives, appliedDirectives, registeredDirective) -> new SchemaDirectiveWiringEnvironmentImpl<>(outputElement, directives, appliedDirectives, registeredDirective, newParams), SchemaDirectiveWiring::onEnum);
}
use of graphql.language.NamedNode in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method onInterface.
public GraphQLInterfaceType onInterface(GraphQLInterfaceType interfaceType, Parameters params) {
List<GraphQLFieldDefinition> startingFields = interfaceType.getFieldDefinitions();
List<GraphQLFieldDefinition> newFields = wireFields(interfaceType, interfaceType.getDefinition(), params);
GraphQLInterfaceType newInterfaceType = interfaceType;
if (isNotTheSameObjects(startingFields, newFields)) {
newInterfaceType = interfaceType.transform(builder -> builder.clearFields().fields(newFields));
}
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(newInterfaceType.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(newInterfaceType);
Parameters newParams = params.newParams(newInterfaceType, nodeParentTree, elementParentTree);
return wireDirectives(params, newInterfaceType, newInterfaceType.getDirectives(), newInterfaceType.getAppliedDirectives(), (outputElement, directives, appliedDirectives, registeredDirective) -> new SchemaDirectiveWiringEnvironmentImpl<>(outputElement, directives, appliedDirectives, registeredDirective, newParams), SchemaDirectiveWiring::onInterface);
}
Aggregations