public Builder(GraphQLInputObjectField existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.defaultValue = existing.getDefaultValue(); this.type = existing.getType(); this.definition = existing.getDefinition(); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
public Builder(GraphQLInputObjectField existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.defaultValue = existing.getDefaultValue(); this.type = existing.getType(); this.definition = existing.getDefinition(); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
@Test public void argMutation() { GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class); GraphQLFieldDefinition doSomethingElse = object.getFieldDefinition("doSomethingElse"); assertNotNull(doSomethingElse); assertEquals(doSomethingElse.getArguments().size(), 1); GraphQLInputType input = doSomethingElse.getArgument("input").getType(); assertTrue(input instanceof GraphQLNonNull); GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType(); assertTrue(inputType instanceof GraphQLInputObjectType); GraphQLInputObjectType inputType_ = (GraphQLInputObjectType) inputType; assertNotNull(inputType_.getField("a")); assertNotNull(inputType_.getField("b")); assertEquals(inputType_.getField("a").getDescription(), "A"); assertTrue(doSomethingElse.getType() instanceof GraphQLObjectType); GraphQLObjectType returnType = (GraphQLObjectType) doSomethingElse.getType(); assertNotNull(returnType.getFieldDefinition("getI")); assertNotNull(returnType.getFieldDefinition("clientMutationId")); GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build(); ExecutionResult result = graphQL.execute("mutation { doSomethingElse(input: {a: 0, b: 1, clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject()); assertEquals(result.getErrors().size(), 0); Map<String, Object> returns = (Map<String, Object>) ((Map<String, Object>) result.getData()).get("doSomethingElse"); assertEquals(returns.get("getI"), -1); assertEquals(returns.get("clientMutationId"), "1"); }