File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
src/test/java/graphql/annotations Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,43 @@ public String fieldWithNamedArgs(@GraphQLName("namedArg") String firstArgument)
133133 }
134134 }
135135
136+ public static class TestMappedObject {
137+ @ GraphQLField
138+ public String name ;
139+ }
140+
141+ public static class TestObjectDB {
142+ public String name ;
143+
144+ public TestObjectDB (String name ) {
145+ this .name = name ;
146+ }
147+ }
148+
149+ public static class TestQuery {
150+ @ GraphQLField
151+ @ GraphQLDataFetcher (ObjectFetcher .class )
152+ public TestMappedObject object ;
153+ }
154+
155+ public static class ObjectFetcher implements DataFetcher <TestObjectDB > {
156+
157+ @ Override
158+ public TestObjectDB get (DataFetchingEnvironment environment ) {
159+ return new TestObjectDB ("test" );
160+ }
161+ }
162+
163+ @ Test
164+ public void fetchTestMappedObject_assertNameIsMappedFromDBObject (){
165+ GraphQLObjectType object = GraphQLAnnotations .object (TestQuery .class );
166+ GraphQLSchema schema = newSchema ().query (object ).build ();
167+
168+ ExecutionResult result = GraphQL .newGraphQL (schema ).build ().execute ("{object {name}}" );
169+ assertTrue (result .getErrors ().isEmpty ());
170+ assertEquals (((LinkedHashMap )(((LinkedHashMap )result .getData ()).get ("object" ))).get ("name" ), "test" );
171+ }
172+
136173 @ Test
137174 public void namedFields () {
138175 GraphQLObjectType object = GraphQLAnnotations .object (TestObjectNamedArgs .class );
You can’t perform that action at this time.
0 commit comments