Search in sources :

Example 1 with InlineFragment

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

the class GraphqlAntlrToLanguage method visitDirective.

@Override
public Void visitDirective(GraphqlParser.DirectiveContext ctx) {
    Directive directive = new Directive(ctx.name().getText());
    newNode(directive, ctx);
    for (ContextEntry contextEntry : contextStack) {
        if (contextEntry.contextProperty == ContextProperty.Field) {
            ((Field) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.FragmentDefinition) {
            ((FragmentDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.FragmentSpread) {
            ((FragmentSpread) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.InlineFragment) {
            ((InlineFragment) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.OperationDefinition) {
            ((OperationDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.EnumValueDefinition) {
            ((EnumValueDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.FieldDefinition) {
            ((FieldDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.InputValueDefinition) {
            ((InputValueDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.InterfaceTypeDefinition) {
            ((InterfaceTypeDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.EnumTypeDefinition) {
            ((EnumTypeDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.ObjectTypeDefinition) {
            ((ObjectTypeDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.ScalarTypeDefinition) {
            ((ScalarTypeDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.UnionTypeDefinition) {
            ((UnionTypeDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.InputObjectTypeDefinition) {
            ((InputObjectTypeDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        } else if (contextEntry.contextProperty == ContextProperty.SchemaDefinition) {
            ((SchemaDefinition) contextEntry.value).getDirectives().add(directive);
            break;
        }
    }
    addContextProperty(ContextProperty.Directive, directive);
    super.visitDirective(ctx);
    popContext();
    return null;
}
Also used : ScalarTypeDefinition(graphql.language.ScalarTypeDefinition) FragmentDefinition(graphql.language.FragmentDefinition) EnumValueDefinition(graphql.language.EnumValueDefinition) EnumTypeDefinition(graphql.language.EnumTypeDefinition) InputObjectTypeDefinition(graphql.language.InputObjectTypeDefinition) InputValueDefinition(graphql.language.InputValueDefinition) Directive(graphql.language.Directive) InlineFragment(graphql.language.InlineFragment)

Example 2 with InlineFragment

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

Aggregations

InlineFragment (graphql.language.InlineFragment)2 Directive (graphql.language.Directive)1 EnumTypeDefinition (graphql.language.EnumTypeDefinition)1 EnumValueDefinition (graphql.language.EnumValueDefinition)1 FragmentDefinition (graphql.language.FragmentDefinition)1 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)1 InputValueDefinition (graphql.language.InputValueDefinition)1 ScalarTypeDefinition (graphql.language.ScalarTypeDefinition)1 TypeName (graphql.language.TypeName)1