Search in sources :

Example 6 with OperationTypeDefinition

use of graphql.language.OperationTypeDefinition in project graphql-java by graphql-java.

the class GraphqlAntlrToLanguage method visitOperationTypeDefinition.

@Override
public Void visitOperationTypeDefinition(GraphqlParser.OperationTypeDefinitionContext ctx) {
    OperationTypeDefinition def = new OperationTypeDefinition(ctx.operationType().getText());
    newNode(def, ctx);
    for (ContextEntry contextEntry : contextStack) {
        if (contextEntry.contextProperty == ContextProperty.SchemaDefinition) {
            ((SchemaDefinition) contextEntry.value).getOperationTypeDefinitions().add(def);
            break;
        }
    }
    addContextProperty(ContextProperty.OperationTypeDefinition, def);
    super.visitChildren(ctx);
    popContext();
    return null;
}
Also used : OperationTypeDefinition(graphql.language.OperationTypeDefinition)

Example 7 with OperationTypeDefinition

use of graphql.language.OperationTypeDefinition in project graphql-java by graphql-java.

the class SchemaDiff method synthOperationTypeDefinition.

// looks for a type called `Query|Mutation|Subscription` and if it exist then assumes it as an operation def
private Optional<OperationTypeDefinition> synthOperationTypeDefinition(Function<Type, Optional<ObjectTypeDefinition>> typeReteriver, String opName) {
    TypeName type = new TypeName(capitalize(opName));
    Optional<ObjectTypeDefinition> typeDef = typeReteriver.apply(type);
    return typeDef.map(objectTypeDefinition -> new OperationTypeDefinition(opName, type));
}
Also used : InputObjectTypeDefinition(graphql.language.InputObjectTypeDefinition) ObjectTypeDefinition(graphql.language.ObjectTypeDefinition) TypeName(graphql.language.TypeName) OperationTypeDefinition(graphql.language.OperationTypeDefinition)

Aggregations

OperationTypeDefinition (graphql.language.OperationTypeDefinition)7 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)5 ObjectTypeDefinition (graphql.language.ObjectTypeDefinition)5 TypeName (graphql.language.TypeName)5 EnumTypeDefinition (graphql.language.EnumTypeDefinition)4 InterfaceTypeDefinition (graphql.language.InterfaceTypeDefinition)4 TypeDefinition (graphql.language.TypeDefinition)4 UnionTypeDefinition (graphql.language.UnionTypeDefinition)4 FieldDefinition (graphql.language.FieldDefinition)3 InputValueDefinition (graphql.language.InputValueDefinition)3 ScalarTypeDefinition (graphql.language.ScalarTypeDefinition)3 SchemaDefinition (graphql.language.SchemaDefinition)3 Type (graphql.language.Type)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Map (java.util.Map)3 GraphQLError (graphql.GraphQLError)2 Directive (graphql.language.Directive)2 EnumValueDefinition (graphql.language.EnumValueDefinition)2 ObjectTypeExtensionDefinition (graphql.language.ObjectTypeExtensionDefinition)2