Search in sources :

Example 11 with TypeName

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

the class GraphqlAntlrToLanguage method visitInlineFragment.

@Override
public Void visitInlineFragment(GraphqlParser.InlineFragmentContext ctx) {
    TypeName typeName = ctx.typeCondition() != null ? new TypeName(ctx.typeCondition().typeName().getText()) : null;
    InlineFragment inlineFragment = new InlineFragment(typeName);
    newNode(inlineFragment, ctx);
    ((SelectionSet) getFromContextStack(ContextProperty.SelectionSet)).getSelections().add(inlineFragment);
    addContextProperty(ContextProperty.InlineFragment, inlineFragment);
    super.visitInlineFragment(ctx);
    popContext();
    return null;
}
Also used : TypeName(graphql.language.TypeName) InlineFragment(graphql.language.InlineFragment)

Example 12 with TypeName

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

the class IntrospectionResultToSchema method createUnion.

@SuppressWarnings("unchecked")
UnionTypeDefinition createUnion(Map<String, Object> input) {
    assertTrue(input.get("kind").equals("UNION"), "wrong input");
    UnionTypeDefinition unionTypeDefinition = new UnionTypeDefinition((String) input.get("name"));
    unionTypeDefinition.setComments(toComment((String) input.get("description")));
    List<Map<String, Object>> possibleTypes = (List<Map<String, Object>>) input.get("possibleTypes");
    for (Map<String, Object> possibleType : possibleTypes) {
        TypeName typeName = new TypeName((String) possibleType.get("name"));
        unionTypeDefinition.getMemberTypes().add(typeName);
    }
    return unionTypeDefinition;
}
Also used : TypeName(graphql.language.TypeName) UnionTypeDefinition(graphql.language.UnionTypeDefinition) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map)

Example 13 with TypeName

use of graphql.language.TypeName 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

TypeName (graphql.language.TypeName)13 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)6 ObjectTypeDefinition (graphql.language.ObjectTypeDefinition)5 UnionTypeDefinition (graphql.language.UnionTypeDefinition)5 EnumTypeDefinition (graphql.language.EnumTypeDefinition)4 InterfaceTypeDefinition (graphql.language.InterfaceTypeDefinition)4 OperationTypeDefinition (graphql.language.OperationTypeDefinition)4 ScalarTypeDefinition (graphql.language.ScalarTypeDefinition)4 TypeDefinition (graphql.language.TypeDefinition)4 List (java.util.List)4 Map (java.util.Map)4 Directive (graphql.language.Directive)3 FieldDefinition (graphql.language.FieldDefinition)3 InputValueDefinition (graphql.language.InputValueDefinition)3 GraphQLType (graphql.schema.GraphQLType)3 GraphQLError (graphql.GraphQLError)2 EnumValueDefinition (graphql.language.EnumValueDefinition)2 InputObjectTypeExtensionDefinition (graphql.language.InputObjectTypeExtensionDefinition)2 SchemaDefinition (graphql.language.SchemaDefinition)2 Type (graphql.language.Type)2