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