@@ -90,141 +90,141 @@ public void notAnObjectType() {
9090 GraphQLObjectType object = GraphQLAnnotations .object (WrongReturnType .class );
9191 }
9292
93- // @Test
94- // public void noArgMutation() {
95- // GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class);
96- //
97- // GraphQLFieldDefinition doSomething = object.getFieldDefinition("doSomething");
98- //
99- // assertNotNull(doSomething);
100- //
101- // assertEquals(doSomething.getArguments().size(), 1);
102- // GraphQLInputType input = doSomething.getArgument("input").getType();
103- // assertTrue(input instanceof GraphQLNonNull);
104- // GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType();
105- // assertTrue(inputType instanceof GraphQLInputObjectType);
106- //
107- // assertTrue(doSomething.getType() instanceof GraphQLObjectType);
108- // GraphQLObjectType returnType = (GraphQLObjectType) doSomething.getType();
109- //
110- // assertNotNull(returnType.getFieldDefinition("i"));
111- // assertNotNull(returnType.getFieldDefinition("clientMutationId"));
112- //
113- // GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build();
114- //
115- // GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build();
116- //
117- // ExecutionResult result = graphQL.execute("mutation { doSomething(input: {clientMutationId: \"1\"}) { i clientMutationId } }", new TestObject());
118- //
119- // assertEquals(result.getErrors().size(), 0);
120- //
121- // Map<String, Object> returns = (Map<String, Object>) ((Map<String, Object>) result.getData()).get("doSomething");
122- //
123- // assertEquals(returns.get("i"), 0);
124- // assertEquals(returns.get("clientMutationId"), "1");
125- // }
126-
127- // @Test
128- // public void interfaceReturningMutation() {
129- // GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class);
130- //
131- // GraphQLFieldDefinition doSomething = object.getFieldDefinition("doSomethingI");
132- //
133- // assertNotNull(doSomething);
134- //
135- // GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build();
136- //
137- // GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build();
138- //
139- // ExecutionResult result = graphQL.execute("mutation { doSomethingI(input: {clientMutationId: \"1\"}) { i clientMutationId } }", new TestObject());
140- //
141- // assertEquals(result.getErrors().size(), 0);
142- //
143- // Map<String, Object> returns = (Map<String, Object>) ((Map<String, Object>) result.getData()).get("doSomethingI");
144- //
145- // assertEquals(returns.get("i"), 0);
146- // assertEquals(returns.get("clientMutationId"), "1");
147- // }
148-
149-
150- // @Test
151- // public void argMutation() {
152- // GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class);
153- //
154- // GraphQLFieldDefinition doSomethingElse = object.getFieldDefinition("doSomethingElse");
155- //
156- // assertNotNull(doSomethingElse);
157- //
158- // assertEquals(doSomethingElse.getArguments().size(), 1);
159- // GraphQLInputType input = doSomethingElse.getArgument("input").getType();
160- // assertTrue(input instanceof GraphQLNonNull);
161- // GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType();
162- // assertTrue(inputType instanceof GraphQLInputObjectType);
163- // GraphQLInputObjectType inputType_ = (GraphQLInputObjectType) inputType;
164- // assertNotNull(inputType_.getField("a"));
165- // assertNotNull(inputType_.getField("b"));
166- // assertEquals(inputType_.getField("a").getDescription(), "A");
167- //
168- // assertTrue(doSomethingElse.getType() instanceof GraphQLObjectType);
169- // GraphQLObjectType returnType = (GraphQLObjectType) doSomethingElse.getType();
170- //
171- // assertNotNull(returnType.getFieldDefinition("i"));
172- // assertNotNull(returnType.getFieldDefinition("clientMutationId"));
173- //
174- // GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build();
175- //
176- // GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build();
177- //
178- // ExecutionResult result = graphQL.execute("mutation { doSomethingElse(input: {a: 0, b: 1, clientMutationId: \"1\"}) { i clientMutationId } }", new TestObject());
179- //
180- // assertEquals(result.getErrors().size(), 0);
181- //
182- // Map<String, Object> returns = (Map<String, Object>) ((Map<String, Object>) result.getData()).get("doSomethingElse");
183- //
184- // assertEquals(returns.get("i"), -1);
185- // assertEquals(returns.get("clientMutationId"), "1");
186- // }
187-
188- // @Test
189- // public void argVariableMutation() {
190- // GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class);
191- //
192- // GraphQLFieldDefinition doSomethingElse = object.getFieldDefinition("doSomethingElse");
193- //
194- // assertNotNull(doSomethingElse);
195- //
196- // assertEquals(doSomethingElse.getArguments().size(), 1);
197- // GraphQLInputType input = doSomethingElse.getArgument("input").getType();
198- // assertTrue(input instanceof GraphQLNonNull);
199- // GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType();
200- // assertTrue(inputType instanceof GraphQLInputObjectType);
201- // GraphQLInputObjectType inputType_ = (GraphQLInputObjectType) inputType;
202- // assertNotNull(inputType_.getField("a"));
203- // assertNotNull(inputType_.getField("b"));
204- //
205- // assertTrue(doSomethingElse.getType() instanceof GraphQLObjectType);
206- // GraphQLObjectType returnType = (GraphQLObjectType) doSomethingElse.getType();
207- //
208- // assertNotNull(returnType.getFieldDefinition("i"));
209- // assertNotNull(returnType.getFieldDefinition("clientMutationId"));
210- //
211- // GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build();
212- //
213- // GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build();
214- //
215- // Map<String, Object> variables = new HashMap<>();
216- // Map<String, Object> inputVariables = new HashMap<>();
217- // inputVariables.put("a", 0);
218- // inputVariables.put("b", 1);
219- // inputVariables.put("clientMutationId", "1");
220- // variables.put("input", inputVariables);
221- // ExecutionResult result = graphQL.execute("mutation VariableMutation($input:DoSomethingElseInput!) { doSomethingElse(input: $input) { i clientMutationId } }", new TestObject(), variables);
222- //
223- // assertEquals(result.getErrors().size(), 0);
224- //
225- // Map<String, Object> returns = (Map<String, Object>) ((Map<String, Object>) result.getData()).get("doSomethingElse");
226- //
227- // assertEquals(returns.get("i"), -1);
228- // assertEquals(returns.get("clientMutationId"), "1");
229- // }
93+ @ Test
94+ public void noArgMutation () {
95+ GraphQLObjectType object = GraphQLAnnotations .object (TestObject .class );
96+
97+ GraphQLFieldDefinition doSomething = object .getFieldDefinition ("doSomething" );
98+
99+ assertNotNull (doSomething );
100+
101+ assertEquals (doSomething .getArguments ().size (), 1 );
102+ GraphQLInputType input = doSomething .getArgument ("input" ).getType ();
103+ assertTrue (input instanceof GraphQLNonNull );
104+ GraphQLType inputType = ((graphql .schema .GraphQLNonNull ) input ).getWrappedType ();
105+ assertTrue (inputType instanceof GraphQLInputObjectType );
106+
107+ assertTrue (doSomething .getType () instanceof GraphQLObjectType );
108+ GraphQLObjectType returnType = (GraphQLObjectType ) doSomething .getType ();
109+
110+ assertNotNull (returnType .getFieldDefinition ("i" ));
111+ assertNotNull (returnType .getFieldDefinition ("clientMutationId" ));
112+
113+ GraphQLSchema schema = GraphQLSchema .newSchema ().query (object ).mutation (object ).build ();
114+
115+ GraphQL graphQL = GraphQL .newGraphQL (schema ).queryExecutionStrategy (new EnhancedExecutionStrategy ()).build ();
116+
117+ ExecutionResult result = graphQL .execute ("mutation { doSomething(input: {clientMutationId: \" 1\" }) { i clientMutationId } }" , new TestObject ());
118+
119+ assertEquals (result .getErrors ().size (), 0 );
120+
121+ Map <String , Object > returns = (Map <String , Object >) ((Map <String , Object >) result .getData ()).get ("doSomething" );
122+
123+ assertEquals (returns .get ("i" ), 0 );
124+ assertEquals (returns .get ("clientMutationId" ), "1" );
125+ }
126+
127+ @ Test
128+ public void interfaceReturningMutation () {
129+ GraphQLObjectType object = GraphQLAnnotations .object (TestObject .class );
130+
131+ GraphQLFieldDefinition doSomething = object .getFieldDefinition ("doSomethingI" );
132+
133+ assertNotNull (doSomething );
134+
135+ GraphQLSchema schema = GraphQLSchema .newSchema ().query (object ).mutation (object ).build ();
136+
137+ GraphQL graphQL = GraphQL .newGraphQL (schema ).queryExecutionStrategy (new EnhancedExecutionStrategy ()).build ();
138+
139+ ExecutionResult result = graphQL .execute ("mutation { doSomethingI(input: {clientMutationId: \" 1\" }) { i clientMutationId } }" , new TestObject ());
140+
141+ assertEquals (result .getErrors ().size (), 0 );
142+
143+ Map <String , Object > returns = (Map <String , Object >) ((Map <String , Object >) result .getData ()).get ("doSomethingI" );
144+
145+ assertEquals (returns .get ("i" ), 0 );
146+ assertEquals (returns .get ("clientMutationId" ), "1" );
147+ }
148+
149+
150+ @ Test
151+ public void argMutation () {
152+ GraphQLObjectType object = GraphQLAnnotations .object (TestObject .class );
153+
154+ GraphQLFieldDefinition doSomethingElse = object .getFieldDefinition ("doSomethingElse" );
155+
156+ assertNotNull (doSomethingElse );
157+
158+ assertEquals (doSomethingElse .getArguments ().size (), 1 );
159+ GraphQLInputType input = doSomethingElse .getArgument ("input" ).getType ();
160+ assertTrue (input instanceof GraphQLNonNull );
161+ GraphQLType inputType = ((graphql .schema .GraphQLNonNull ) input ).getWrappedType ();
162+ assertTrue (inputType instanceof GraphQLInputObjectType );
163+ GraphQLInputObjectType inputType_ = (GraphQLInputObjectType ) inputType ;
164+ assertNotNull (inputType_ .getField ("a" ));
165+ assertNotNull (inputType_ .getField ("b" ));
166+ assertEquals (inputType_ .getField ("a" ).getDescription (), "A" );
167+
168+ assertTrue (doSomethingElse .getType () instanceof GraphQLObjectType );
169+ GraphQLObjectType returnType = (GraphQLObjectType ) doSomethingElse .getType ();
170+
171+ assertNotNull (returnType .getFieldDefinition ("i" ));
172+ assertNotNull (returnType .getFieldDefinition ("clientMutationId" ));
173+
174+ GraphQLSchema schema = GraphQLSchema .newSchema ().query (object ).mutation (object ).build ();
175+
176+ GraphQL graphQL = GraphQL .newGraphQL (schema ).queryExecutionStrategy (new EnhancedExecutionStrategy ()).build ();
177+
178+ ExecutionResult result = graphQL .execute ("mutation { doSomethingElse(input: {a: 0, b: 1, clientMutationId: \" 1\" }) { i clientMutationId } }" , new TestObject ());
179+
180+ assertEquals (result .getErrors ().size (), 0 );
181+
182+ Map <String , Object > returns = (Map <String , Object >) ((Map <String , Object >) result .getData ()).get ("doSomethingElse" );
183+
184+ assertEquals (returns .get ("i" ), -1 );
185+ assertEquals (returns .get ("clientMutationId" ), "1" );
186+ }
187+
188+ @ Test
189+ public void argVariableMutation () {
190+ GraphQLObjectType object = GraphQLAnnotations .object (TestObject .class );
191+
192+ GraphQLFieldDefinition doSomethingElse = object .getFieldDefinition ("doSomethingElse" );
193+
194+ assertNotNull (doSomethingElse );
195+
196+ assertEquals (doSomethingElse .getArguments ().size (), 1 );
197+ GraphQLInputType input = doSomethingElse .getArgument ("input" ).getType ();
198+ assertTrue (input instanceof GraphQLNonNull );
199+ GraphQLType inputType = ((graphql .schema .GraphQLNonNull ) input ).getWrappedType ();
200+ assertTrue (inputType instanceof GraphQLInputObjectType );
201+ GraphQLInputObjectType inputType_ = (GraphQLInputObjectType ) inputType ;
202+ assertNotNull (inputType_ .getField ("a" ));
203+ assertNotNull (inputType_ .getField ("b" ));
204+
205+ assertTrue (doSomethingElse .getType () instanceof GraphQLObjectType );
206+ GraphQLObjectType returnType = (GraphQLObjectType ) doSomethingElse .getType ();
207+
208+ assertNotNull (returnType .getFieldDefinition ("i" ));
209+ assertNotNull (returnType .getFieldDefinition ("clientMutationId" ));
210+
211+ GraphQLSchema schema = GraphQLSchema .newSchema ().query (object ).mutation (object ).build ();
212+
213+ GraphQL graphQL = GraphQL .newGraphQL (schema ).queryExecutionStrategy (new EnhancedExecutionStrategy ()).build ();
214+
215+ Map <String , Object > variables = new HashMap <>();
216+ Map <String , Object > inputVariables = new HashMap <>();
217+ inputVariables .put ("a" , 0 );
218+ inputVariables .put ("b" , 1 );
219+ inputVariables .put ("clientMutationId" , "1" );
220+ variables .put ("input" , inputVariables );
221+ ExecutionResult result = graphQL .execute ("mutation VariableMutation($input:DoSomethingElseInput!) { doSomethingElse(input: $input) { i clientMutationId } }" , new TestObject (), variables );
222+
223+ assertEquals (result .getErrors ().size (), 0 );
224+
225+ Map <String , Object > returns = (Map <String , Object >) ((Map <String , Object >) result .getData ()).get ("doSomethingElse" );
226+
227+ assertEquals (returns .get ("i" ), -1 );
228+ assertEquals (returns .get ("clientMutationId" ), "1" );
229+ }
230230}
0 commit comments