/** * A factory method for creating type references so that when used with static imports allows * more readable code such as * {@code .type(typeRef(GraphQLString)) } * * @param typeName the name of the type to reference * * @return a GraphQLTypeReference of that named type */ public static GraphQLTypeReference typeRef(String typeName) { return new GraphQLTypeReference(typeName); }
void recursiveTypes() { GraphQLObjectType person = newObject() .name("Person") .field(newFieldDefinition() .name("friends") .type(GraphQLList.list(GraphQLTypeReference.typeRef("Person")))) .build(); }
public Builder withInterface(GraphQLTypeReference reference) { assertNotNull(reference, "reference can't be null"); this.interfaces.put(reference.getName(), reference); return this; }
.description( "Needed until https://github.com/facebook/relay/issues/112 is resolved") .type(new GraphQLTypeReference("QueryType")) .dataFetcher(DataFetchingEnvironment::getParentType) .build())
private GraphQLInputType buildInputType(BuildContext buildCtx, Type rawType) { TypeDefinition typeDefinition = buildCtx.getTypeDefinition(rawType); TypeInfo typeInfo = TypeInfo.typeInfo(rawType); GraphQLInputType inputType = buildCtx.hasInputType(typeDefinition); if (inputType != null) { return typeInfo.decorate(inputType); } if (buildCtx.stackContains(typeInfo)) { // we have circled around so put in a type reference and fix it later return typeInfo.decorate(typeRef(typeInfo.getName())); } buildCtx.push(typeInfo); if (typeDefinition instanceof InputObjectTypeDefinition) { inputType = buildInputObjectType(buildCtx, (InputObjectTypeDefinition) typeDefinition); } else if (typeDefinition instanceof EnumTypeDefinition) { inputType = buildEnumType(buildCtx, (EnumTypeDefinition) typeDefinition); } else if (typeDefinition instanceof ScalarTypeDefinition) { inputType = buildScalar(buildCtx, (ScalarTypeDefinition) typeDefinition); } else { // typeDefinition is not a valid InputType throw new NotAnInputTypeError(rawType, typeDefinition); } buildCtx.putInputType(inputType); buildCtx.pop(); return typeInfo.decorate(inputType); }
public Builder possibleType(GraphQLTypeReference reference) { assertNotNull(reference, "reference can't be null"); types.put(reference.getName(), reference); return this; }
/** * A factory method for creating type references so that when used with static imports allows * more readable code such as * {@code .type(typeRef(GraphQLString)) } * * @param typeName the name of the type to reference * * @return a GraphQLTypeReference of that named type */ public static GraphQLTypeReference typeRef(String typeName) { return new GraphQLTypeReference(typeName); }
return typeInfo.decorate(typeRef(typeInfo.getName()));
public TraversalControl handleTypeReference(GraphQLTypeReference node, TraverserContext<GraphQLType> context) { final GraphQLType resolvedType = typeMap.get(node.getName()); assertNotNull(resolvedType, "type %s not found in schema", node.getName()); context.getParentContext().thisNode().accept(context, new TypeRefResolvingVisitor(resolvedType)); return CONTINUE; }
@Override public GraphQLTypeReference getTypeRef() { return new GraphQLTypeReference(STANDARD_BUILD_FILTER); }
.field(newFieldDefinition() .name("shatter") .type(nonNull(list(nonNull(typeRef("StringObject"))))) .dataFetcher(shatterFetcher)) .type(nonNull(list(nonNull(list(nonNull(typeRef("StringObject"))))))) .dataFetcher(wordsAndLettersFetcher)) .name("split") .description("String#split(regex) but replace empty strings with nulls to help us test null behavior in lists") .type(list(typeRef("StringObject"))) .argument(GraphQLArgument.newArgument() .name("regex") .name("splitNotNull") .description("String#split(regex) but replace empty strings with nulls to help us test null behavior in lists") .type(list(nonNull(typeRef("StringObject")))) .argument(GraphQLArgument.newArgument() .name("regex") .type(typeRef("StringObject")) .argument(GraphQLArgument.newArgument() .name("text") .withInterface(typeRef("InterfaceType")) .field(newFieldDefinition() .name("value")
public Builder withInterface(GraphQLTypeReference reference) { assertNotNull(reference, "reference can't be null"); this.interfaces.put(reference.getName(), reference); return this; }
public static GraphQLTypeReference ref (String aName) { return new GraphQLTypeReference(aName); }
@Override public GraphQLInputType getType() { if (byRef) { return GraphQLTypeReference.typeRef(NAME); } else { return super.getType(); } }
public Builder possibleType(GraphQLTypeReference reference) { assertNotNull(reference, "reference can't be null"); types.put(reference.getName(), reference); return this; }
public static GraphQLTypeReference ref (String aName) { return new GraphQLTypeReference(aName); }
private GraphQLInputType buildInputType(BuildContext buildCtx, Type rawType) { TypeDefinition typeDefinition = buildCtx.getTypeDefinition(rawType); TypeInfo typeInfo = TypeInfo.typeInfo(rawType); GraphQLInputType inputType = buildCtx.hasInputType(typeDefinition); if (inputType != null) { return typeInfo.decorate(inputType); } if (buildCtx.stackContains(typeInfo)) { // we have circled around so put in a type reference and fix it later return typeInfo.decorate(typeRef(typeInfo.getName())); } buildCtx.push(typeInfo); if (typeDefinition instanceof InputObjectTypeDefinition) { inputType = buildInputObjectType(buildCtx, (InputObjectTypeDefinition) typeDefinition); } else if (typeDefinition instanceof EnumTypeDefinition) { inputType = buildEnumType(buildCtx, (EnumTypeDefinition) typeDefinition); } else if (typeDefinition instanceof ScalarTypeDefinition) { inputType = buildScalar(buildCtx, (ScalarTypeDefinition) typeDefinition); } else { // typeDefinition is not a valid InputType throw new NotAnInputTypeError(rawType, typeDefinition); } buildCtx.putInputType(inputType); buildCtx.pop(); return typeInfo.decorate(inputType); }
public TraversalControl handleTypeReference(GraphQLTypeReference node, TraverserContext<GraphQLType> context) { final GraphQLType resolvedType = typeMap.get(node.getName()); assertNotNull(resolvedType, "type %s not found in schema", node.getName()); context.getParentContext().thisNode().accept(context, new TypeRefResolvingVisitor(resolvedType)); return CONTINUE; }
@Override public GraphQLTypeReference getTypeRef() { return new GraphQLTypeReference(BuildSearchForm.class.getSimpleName()); }
return typeInfo.decorate(typeRef(typeInfo.getName()));