Search in sources :

Example 6 with NamedNode

use of graphql.language.NamedNode 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);
}
Also used : GraphQLSchemaElement(graphql.schema.GraphQLSchemaElement) GraphQLCodeRegistry(graphql.schema.GraphQLCodeRegistry) Internal(graphql.Internal) GraphQLDirectiveContainer(graphql.schema.GraphQLDirectiveContainer) GraphQLInputObjectType(graphql.schema.GraphQLInputObjectType) GraphQLScalarType(graphql.schema.GraphQLScalarType) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) GraphQLInterfaceType(graphql.schema.GraphQLInterfaceType) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) GraphQLUnionType(graphql.schema.GraphQLUnionType) HashMap(java.util.HashMap) GraphQLEnumValueDefinition(graphql.schema.GraphQLEnumValueDefinition) Deque(java.util.Deque) GraphQLAppliedDirective(graphql.schema.GraphQLAppliedDirective) NodeParentTree(graphql.language.NodeParentTree) Map(java.util.Map) GraphQLObjectType(graphql.schema.GraphQLObjectType) GraphQLDirective(graphql.schema.GraphQLDirective) GraphQLArgument(graphql.schema.GraphQLArgument) List(java.util.List) GraphqlElementParentTree(graphql.schema.GraphqlElementParentTree) ImmutableKit.map(graphql.collect.ImmutableKit.map) Assert.assertNotNull(graphql.Assert.assertNotNull) NamedNode(graphql.language.NamedNode) GraphQLEnumType(graphql.schema.GraphQLEnumType) ArrayDeque(java.util.ArrayDeque) GraphQLFieldsContainer(graphql.schema.GraphQLFieldsContainer) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) GraphQLInputObjectType(graphql.schema.GraphQLInputObjectType) NamedNode(graphql.language.NamedNode) GraphqlElementParentTree(graphql.schema.GraphqlElementParentTree)

Example 7 with NamedNode

use of graphql.language.NamedNode 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);
}
Also used : GraphQLSchemaElement(graphql.schema.GraphQLSchemaElement) GraphQLCodeRegistry(graphql.schema.GraphQLCodeRegistry) Internal(graphql.Internal) GraphQLDirectiveContainer(graphql.schema.GraphQLDirectiveContainer) GraphQLInputObjectType(graphql.schema.GraphQLInputObjectType) GraphQLScalarType(graphql.schema.GraphQLScalarType) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) GraphQLInterfaceType(graphql.schema.GraphQLInterfaceType) GraphQLInputObjectField(graphql.schema.GraphQLInputObjectField) GraphQLUnionType(graphql.schema.GraphQLUnionType) HashMap(java.util.HashMap) GraphQLEnumValueDefinition(graphql.schema.GraphQLEnumValueDefinition) Deque(java.util.Deque) GraphQLAppliedDirective(graphql.schema.GraphQLAppliedDirective) NodeParentTree(graphql.language.NodeParentTree) Map(java.util.Map) GraphQLObjectType(graphql.schema.GraphQLObjectType) GraphQLDirective(graphql.schema.GraphQLDirective) GraphQLArgument(graphql.schema.GraphQLArgument) List(java.util.List) GraphqlElementParentTree(graphql.schema.GraphqlElementParentTree) ImmutableKit.map(graphql.collect.ImmutableKit.map) Assert.assertNotNull(graphql.Assert.assertNotNull) NamedNode(graphql.language.NamedNode) GraphQLEnumType(graphql.schema.GraphQLEnumType) ArrayDeque(java.util.ArrayDeque) GraphQLFieldsContainer(graphql.schema.GraphQLFieldsContainer) GraphQLObjectType(graphql.schema.GraphQLObjectType) GraphQLFieldDefinition(graphql.schema.GraphQLFieldDefinition) NamedNode(graphql.language.NamedNode) GraphqlElementParentTree(graphql.schema.GraphqlElementParentTree)

Example 8 with NamedNode

use of graphql.language.NamedNode 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);
}
Also used : NamedNode(graphql.language.NamedNode) GraphqlElementParentTree(graphql.schema.GraphqlElementParentTree)

Aggregations

NamedNode (graphql.language.NamedNode)8 GraphqlElementParentTree (graphql.schema.GraphqlElementParentTree)8 Assert.assertNotNull (graphql.Assert.assertNotNull)5 Internal (graphql.Internal)5 ImmutableKit.map (graphql.collect.ImmutableKit.map)5 NodeParentTree (graphql.language.NodeParentTree)5 GraphQLAppliedDirective (graphql.schema.GraphQLAppliedDirective)5 GraphQLArgument (graphql.schema.GraphQLArgument)5 GraphQLCodeRegistry (graphql.schema.GraphQLCodeRegistry)5 GraphQLDirective (graphql.schema.GraphQLDirective)5 GraphQLDirectiveContainer (graphql.schema.GraphQLDirectiveContainer)5 GraphQLEnumType (graphql.schema.GraphQLEnumType)5 GraphQLEnumValueDefinition (graphql.schema.GraphQLEnumValueDefinition)5 GraphQLFieldDefinition (graphql.schema.GraphQLFieldDefinition)5 GraphQLFieldsContainer (graphql.schema.GraphQLFieldsContainer)5 GraphQLInputObjectField (graphql.schema.GraphQLInputObjectField)5 GraphQLInputObjectType (graphql.schema.GraphQLInputObjectType)5 GraphQLInterfaceType (graphql.schema.GraphQLInterfaceType)5 GraphQLObjectType (graphql.schema.GraphQLObjectType)5 GraphQLScalarType (graphql.schema.GraphQLScalarType)5