Skip to content

Commit

Permalink
Add introspection query test
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesj committed Aug 17, 2015
1 parent c4229fc commit 3a1339d
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 4 deletions.
Expand Up @@ -915,6 +915,7 @@ public IndexGraphQLSchema(GraphIndex index) {


indexSchema = GraphQLSchema.newSchema() indexSchema = GraphQLSchema.newSchema()
.query(queryType) .query(queryType)
.mutation(GraphQLObjectType.newObject().name("MutationType").build()) //Empty mutation type
.build(); .build();
} }
} }
@@ -1,5 +1,6 @@
package org.opentripplanner.routing.graph; package org.opentripplanner.routing.graph;


import graphql.ExecutionResult;
import org.onebusaway.gtfs.model.Agency; import org.onebusaway.gtfs.model.Agency;
import org.onebusaway.gtfs.model.AgencyAndId; import org.onebusaway.gtfs.model.AgencyAndId;
import org.onebusaway.gtfs.model.Route; import org.onebusaway.gtfs.model.Route;
Expand Down Expand Up @@ -104,8 +105,9 @@ public void testGraphQLSimple() {
" }" + " }" +
"}"; "}";


Map result = graph.index.graphQL.execute(query).getData(); ExecutionResult result = graph.index.graphQL.execute(query);
assertEquals("Fake Agency", ((Map) result.get("agency")).get("name")); assertTrue(result.getErrors().isEmpty());
assertEquals("Fake Agency", ((Map) result.getData().get("agency")).get("name"));


} }


Expand All @@ -120,11 +122,94 @@ public void testGraphQLNested() {
" }\n" + " }\n" +
"}\n"; "}\n";


Map result = graph.index.graphQL.execute(query).getData(); ExecutionResult result = graph.index.graphQL.execute(query);
assertEquals(18, ((List) ((Map) result.get("agency")).get("routes")).size()); assertTrue(result.getErrors().isEmpty());
assertEquals(18, ((List) ((Map) result.getData().get("agency")).get("routes")).size());


} }


public void testGraphQLIntrospectionQuery() {
String query = " query IntrospectionQuery {\n"
+ " __schema {\n"
+ " queryType { name }\n"
+ " mutationType { name }\n"
+ " types {\n"
+ " ...FullType\n"
+ " }\n"
+ " directives {\n"
+ " name\n"
+ " description\n"
+ " args {\n"
+ " ...InputValue\n"
+ " }\n"
+ " onOperation\n"
+ " onFragment\n"
+ " onField\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " fragment FullType on __Type {\n"
+ " kind\n"
+ " name\n"
+ " description\n"
+ " fields {\n"
+ " name\n"
+ " description\n"
+ " args {\n"
+ " ...InputValue\n"
+ " }\n"
+ " type {\n"
+ " ...TypeRef\n"
+ " }\n"
+ " isDeprecated\n"
+ " deprecationReason\n"
+ " }\n"
+ " inputFields {\n"
+ " ...InputValue\n"
+ " }\n"
+ " interfaces {\n"
+ " ...TypeRef\n"
+ " }\n"
+ " enumValues {\n"
+ " name\n"
+ " description\n"
+ " isDeprecated\n"
+ " deprecationReason\n"
+ " }\n"
+ " possibleTypes {\n"
+ " ...TypeRef\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " fragment InputValue on __InputValue {\n"
+ " name\n"
+ " description\n"
+ " type { ...TypeRef }\n"
+ " defaultValue\n"
+ " }\n"
+ "\n"
+ " fragment TypeRef on __Type {\n"
+ " kind\n"
+ " name\n"
+ " ofType {\n"
+ " kind\n"
+ " name\n"
+ " ofType {\n"
+ " kind\n"
+ " name\n"
+ " ofType {\n"
+ " kind\n"
+ " name\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }";

ExecutionResult result = graph.index.graphQL.execute(query);
assertTrue(result.getErrors().isEmpty());
}



public void testParentStations() { public void testParentStations() {
// graph.index.stopsForParentStation; // graph.index.stopsForParentStation;
Expand Down

0 comments on commit 3a1339d

Please sign in to comment.