@Override protected void handleExtraFieldError(Value value, GraphQLInputObjectType type, ObjectField objectField) { errorMessage = "contains a field not in '%s': '%s'"; arguments.add(type.getName()); arguments.add(objectField.getName()); }
@Override public TraversalControl visitGraphQLInputObjectType(GraphQLInputObjectType node, TraverserContext<GraphQLType> context) { if (isTypeReference(node.getName())) { assertTypeUniqueness(node, result); } else { save(node.getName(), node); } return super.visitGraphQLInputObjectType(node, context); }
public Builder(GraphQLInputObjectType existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.definition = existing.getDefinition(); this.fields.putAll(getByName(existing.getFields(), GraphQLInputObjectField::getName)); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
private TypePrinter<GraphQLInputObjectType> inputObjectPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); out.format("input %s%s {\n", type.getName(), directivesString(type.getDirectives())); visibility.getFieldDefinitions(type) .stream() .sorted(Comparator.comparing(GraphQLInputObjectField::getName)) .forEach(fd -> { printComments(out, fd, " "); out.format(" %s: %s", fd.getName(), typeString(fd.getType())); Object defaultValue = fd.getDefaultValue(); if (defaultValue != null) { String astValue = printAst(defaultValue, fd.getType()); out.format(" = %s", astValue); } out.format(directivesString(fd.getDirectives())); out.format("\n"); }); out.format("}\n\n"); }; }
@Override protected void handleExtraFieldError(Value value, GraphQLInputObjectType type, ObjectField objectField) { errorMessage = "contains a field not in '%s': '%s'"; arguments.add(type.getName()); arguments.add(objectField.getName()); }
@Override public TraversalControl visitGraphQLInputObjectType(GraphQLInputObjectType node, TraverserContext<GraphQLType> context) { if (isTypeReference(node.getName())) { assertTypeUniqueness(node, result); } else { save(node.getName(), node); } return super.visitGraphQLInputObjectType(node, context); }
public Builder(GraphQLInputObjectType existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.definition = existing.getDefinition(); this.fields.putAll(getByName(existing.getFields(), GraphQLInputObjectField::getName)); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
private TypePrinter<GraphQLInputObjectType> inputObjectPrinter() { return (out, type, visibility) -> { if (isIntrospectionType(type)) { return; } printComments(out, type, ""); SchemaPrinterComparatorEnvironment environment = SchemaPrinterComparatorEnvironment.newEnvironment() .parentType(GraphQLInputObjectType.class) .elementType(GraphQLInputObjectField.class) .build(); Comparator<? super GraphQLType> comparator = options.comparatorRegistry.getComparator(environment); out.format("input %s%s {\n", type.getName(), directivesString(GraphQLInputObjectType.class, type.getDirectives())); visibility.getFieldDefinitions(type) .stream() .sorted(comparator) .forEach(fd -> { printComments(out, fd, " "); out.format(" %s: %s", fd.getName(), typeString(fd.getType())); Object defaultValue = fd.getDefaultValue(); if (defaultValue != null) { String astValue = printAst(defaultValue, fd.getType()); out.format(" = %s", astValue); } out.format(directivesString(GraphQLInputObjectField.class, fd.getDirectives())); out.format("\n"); }); out.format("}\n\n"); }; }
@Test public void inputObject() { GraphQLObjectInfoRetriever graphQLObjectInfoRetriever = new GraphQLObjectInfoRetriever(); GraphQLInputObjectType type = new InputObjectBuilder(graphQLObjectInfoRetriever, new ParentalSearch(graphQLObjectInfoRetriever), new BreadthFirstSearch(graphQLObjectInfoRetriever), new GraphQLFieldRetriever()). getInputObjectBuilder(InputObject.class, GraphQLAnnotations.getInstance().getContainer()).build(); assertEquals(type.getName(), DEFAULT_INPUT_PREFIX + InputObject.class.getSimpleName(), "Type name prefix did not match expected value"); assertEquals(type.getFields().size(), InputObject.class.getDeclaredFields().length); }
@Test public void inputObjectCustomPrefixes() { GraphQLObjectInfoRetriever graphQLObjectInfoRetriever = new GraphQLObjectInfoRetriever(); ProcessingElementsContainer container = GraphQLAnnotations.getInstance().getContainer(); container.setInputPrefix(""); container.setInputSuffix("Input"); GraphQLInputObjectType type = new InputObjectBuilder(graphQLObjectInfoRetriever, new ParentalSearch(graphQLObjectInfoRetriever), new BreadthFirstSearch(graphQLObjectInfoRetriever), new GraphQLFieldRetriever()). getInputObjectBuilder(InputObject.class, GraphQLAnnotations.getInstance().getContainer()).build(); assertEquals(type.getName(), "" + InputObject.class.getSimpleName() + "Input", "Type name prefix did not match expected value"); assertEquals(type.getFields().size(), InputObject.class.getDeclaredFields().length); container.setInputPrefix(DEFAULT_INPUT_PREFIX); container.setInputSuffix(DEFAULT_INPUT_SUFFIX); }