use of graphql.schema.GraphqlElementParentTree in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method onInputObjectType.
public GraphQLInputObjectType onInputObjectType(GraphQLInputObjectType inputObjectType, Parameters params) {
List<GraphQLInputObjectField> startingFields = inputObjectType.getFieldDefinitions();
List<GraphQLInputObjectField> newFields = map(startingFields, inputField -> {
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(inputObjectType.getDefinition(), inputField.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(inputObjectType, inputField);
Parameters fieldParams = params.newParams(nodeParentTree, elementParentTree);
// now for each field run the new wiring and capture the results
return onInputObjectField(inputField, fieldParams);
});
GraphQLInputObjectType newInputObjectType = inputObjectType;
if (isNotTheSameObjects(startingFields, newFields)) {
newInputObjectType = inputObjectType.transform(builder -> builder.clearFields().fields(newFields));
}
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(newInputObjectType.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(newInputObjectType);
Parameters newParams = params.newParams(nodeParentTree, elementParentTree);
return wireDirectives(params, newInputObjectType, newInputObjectType.getDirectives(), newInputObjectType.getAppliedDirectives(), (outputElement, directives, appliedDirectives, registeredDirective) -> new SchemaDirectiveWiringEnvironmentImpl<>(outputElement, directives, appliedDirectives, registeredDirective, newParams), SchemaDirectiveWiring::onInputObjectType);
}
use of graphql.schema.GraphqlElementParentTree in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method onObject.
public GraphQLObjectType onObject(GraphQLObjectType objectType, Parameters params) {
List<GraphQLFieldDefinition> startingFields = objectType.getFieldDefinitions();
List<GraphQLFieldDefinition> newFields = wireFields(objectType, objectType.getDefinition(), params);
GraphQLObjectType newObjectType = objectType;
if (isNotTheSameObjects(startingFields, newFields)) {
newObjectType = objectType.transform(builder -> builder.clearFields().fields(newFields));
}
NodeParentTree<NamedNode<?>> nodeParentTree = buildAstTree(newObjectType.getDefinition());
GraphqlElementParentTree elementParentTree = buildRuntimeTree(newObjectType);
Parameters newParams = params.newParams(newObjectType, nodeParentTree, elementParentTree);
return wireDirectives(params, newObjectType, newObjectType.getDirectives(), newObjectType.getAppliedDirectives(), (outputElement, directives, appliedDirectives, registeredDirective) -> new SchemaDirectiveWiringEnvironmentImpl<>(outputElement, directives, appliedDirectives, registeredDirective, newParams), SchemaDirectiveWiring::onObject);
}
use of graphql.schema.GraphqlElementParentTree in project graphql-java by graphql-java.
the class SchemaGeneratorDirectiveHelper method onScalar.
public GraphQLScalarType onScalar(GraphQLScalarType 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::onScalar);
}
Aggregations