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;
}
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;
}
Aggregations