From 9a8d1638b5dea53fa4457b12fe1ac423b36fa2f4 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 4 Aug 2018 21:49:13 -0400 Subject: [PATCH] listType - listOf --- angel_graphql/example/main.dart | 2 +- example_star_wars/lib/star_wars.dart | 6 +++--- graphql_schema/README.md | 4 ++-- graphql_schema/lib/src/type.dart | 2 +- graphql_schema/test/common.dart | 2 +- graphql_schema/test/serialize_test.dart | 4 ++-- graphql_server/lib/introspection.dart | 20 ++++++++++---------- graphql_server/lib/mirrors.dart | 2 +- graphql_server/test/query_test.dart | 2 +- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/angel_graphql/example/main.dart b/angel_graphql/example/main.dart index 0d1633b7..59891773 100644 --- a/angel_graphql/example/main.dart +++ b/angel_graphql/example/main.dart @@ -25,7 +25,7 @@ main() async { fields: [ field( 'todos', - listType(convertDartType(Todo).nonNullable()), + listOf(convertDartType(Todo).nonNullable()), resolve: resolveViaServiceIndex(todoService), ), field( diff --git a/example_star_wars/lib/star_wars.dart b/example_star_wars/lib/star_wars.dart index 9334d00e..e3c9656a 100644 --- a/example_star_wars/lib/star_wars.dart +++ b/example_star_wars/lib/star_wars.dart @@ -37,19 +37,19 @@ Future configureServer(Angel app) async { fields: [ field( 'droids', - listType(droidType.nonNullable()), + listOf(droidType.nonNullable()), description: 'All droids in the known galaxy.', resolve: resolveViaServiceIndex(droidService), ), field( 'humans', - listType(humanType.nonNullable()), + listOf(humanType.nonNullable()), description: 'All humans in the known galaxy.', resolve: resolveViaServiceIndex(humansService), ), field( 'starships', - listType(starshipType.nonNullable()), + listOf(starshipType.nonNullable()), description: 'All starships in the known galaxy.', resolve: resolveViaServiceIndex(starshipService), ), diff --git a/graphql_schema/README.md b/graphql_schema/README.md index 8fd81906..bd8af159 100644 --- a/graphql_schema/README.md +++ b/graphql_schema/README.md @@ -69,7 +69,7 @@ Support for list types is also included. Use the `listType` helper for convenien ```dart /// A non-nullable list of non-nullable integers -listType(graphQLInt.nonNullable()).nonNullable(); +listOf(graphQLInt.nonNullable()).nonNullable(); ``` ### Input values and parameters @@ -92,7 +92,7 @@ The field `characters` accepts a parameter, `title`. To reproduce this in ```dart final GraphQLObjectType queryType = objectType('AnimeQuery', fields: [ field('characters', - listType(characterType.nonNullable()), + listOf(characterType.nonNullable()), inputs: [ new GraphQLFieldInput('title', graphQLString.nonNullable()) ] diff --git a/graphql_schema/lib/src/type.dart b/graphql_schema/lib/src/type.dart index 5b04925f..60026999 100644 --- a/graphql_schema/lib/src/type.dart +++ b/graphql_schema/lib/src/type.dart @@ -20,7 +20,7 @@ abstract class GraphQLType { } /// Shorthand to create a [GraphQLListType]. -GraphQLListType listType( +GraphQLListType listOf( GraphQLType innerType) => new GraphQLListType(innerType); diff --git a/graphql_schema/test/common.dart b/graphql_schema/test/common.dart index f554a477..01b7636d 100644 --- a/graphql_schema/test/common.dart +++ b/graphql_schema/test/common.dart @@ -11,5 +11,5 @@ final GraphQLObjectType trainerType = final GraphQLObjectType pokemonRegionType = objectType('PokemonRegion', fields: [ field('trainer', trainerType), - field('pokemon_species', listType(pokemonType)) + field('pokemon_species', listOf(pokemonType)) ]); diff --git a/graphql_schema/test/serialize_test.dart b/graphql_schema/test/serialize_test.dart index 5725df02..a27bf1ec 100644 --- a/graphql_schema/test/serialize_test.dart +++ b/graphql_schema/test/serialize_test.dart @@ -36,11 +36,11 @@ main() { }); test('list', () { - expect(listType(graphQLString).serialize(['foo', 'bar']), ['foo', 'bar']); + expect(listOf(graphQLString).serialize(['foo', 'bar']), ['foo', 'bar']); var today = new DateTime.now(); var tomorrow = today.add(new Duration(days: 1)); - expect(listType(graphQLDate).serialize([today, tomorrow]), + expect(listOf(graphQLDate).serialize([today, tomorrow]), [today.toIso8601String(), tomorrow.toIso8601String()]); }); diff --git a/graphql_server/lib/introspection.dart b/graphql_server/lib/introspection.dart index b7dc685c..ccdb7a28 100644 --- a/graphql_server/lib/introspection.dart +++ b/graphql_server/lib/introspection.dart @@ -22,7 +22,7 @@ GraphQLSchema reflectSchema(GraphQLSchema schema, List allTypes) { var schemaType = objectType('__Schema', fields: [ field( 'types', - listType(typeType), + listOf(typeType), resolve: (_, __) => allTypeSet ??= allTypes.toSet(), ), field( @@ -42,7 +42,7 @@ GraphQLSchema reflectSchema(GraphQLSchema schema, List allTypes) { ), field( 'directives', - listType(directiveType).nonNullable(), + listOf(directiveType).nonNullable(), resolve: (_, __) => [], // TODO: Actually fetch directives ), ]); @@ -113,7 +113,7 @@ GraphQLObjectType _reflectSchemaTypes() { _typeType.fields.add( field( 'interfaces', - listType(_reflectSchemaTypes().nonNullable()), + listOf(_reflectSchemaTypes().nonNullable()), resolve: (type, _) { if (type is GraphQLObjectType) { return type.interfaces; @@ -127,7 +127,7 @@ GraphQLObjectType _reflectSchemaTypes() { _typeType.fields.add( field( 'possibleTypes', - listType(_reflectSchemaTypes().nonNullable()), + listOf(_reflectSchemaTypes().nonNullable()), resolve: (type, _) { if (type is GraphQLObjectType && type.isInterface) { return type.possibleTypes; @@ -227,7 +227,7 @@ GraphQLObjectType _createTypeType() { ), field( 'fields', - listType(fieldType), + listOf(fieldType), inputs: [ new GraphQLFieldInput( 'includeDeprecated', @@ -244,7 +244,7 @@ GraphQLObjectType _createTypeType() { ), field( 'enumValues', - listType(enumValueType.nonNullable()), + listOf(enumValueType.nonNullable()), inputs: [ new GraphQLFieldInput( 'includeDeprecated', @@ -265,7 +265,7 @@ GraphQLObjectType _createTypeType() { ), field( 'inputFields', - listType(inputValueType.nonNullable()), + listOf(inputValueType.nonNullable()), resolve: (obj, _) { if (obj is GraphQLInputObjectType) { return obj.inputFields; @@ -313,7 +313,7 @@ GraphQLObjectType _createFieldType() { ), field( 'args', - listType(inputValueType.nonNullable()).nonNullable(), + listOf(inputValueType.nonNullable()).nonNullable(), resolve: (f, _) => (f as GraphQLObjectField).inputs, ), ]); @@ -384,13 +384,13 @@ GraphQLObjectType _reflectDirectiveType() { ), field( 'locations', - listType(_directiveLocationType.nonNullable()).nonNullable(), + listOf(_directiveLocationType.nonNullable()).nonNullable(), // TODO: Fetch directiveLocation resolve: (obj, _) => [], ), field( 'args', - listType(inputValueType.nonNullable()).nonNullable(), + listOf(inputValueType.nonNullable()).nonNullable(), resolve: (obj, _) => [], ), ]); diff --git a/graphql_server/lib/mirrors.dart b/graphql_server/lib/mirrors.dart index 6dc70e39..b330f36c 100644 --- a/graphql_server/lib/mirrors.dart +++ b/graphql_server/lib/mirrors.dart @@ -55,7 +55,7 @@ GraphQLType _objectTypeFromDartType(Type type, [List typeArguments]) { if (clazz.typeArguments.isNotEmpty) { var inner = convertDartType(clazz.typeArguments[0].reflectedType); //if (inner == null) return null; - return listType(inner.nonNullable()); + return listOf(inner.nonNullable()); } throw new ArgumentError( diff --git a/graphql_server/test/query_test.dart b/graphql_server/test/query_test.dart index b511bb57..c008fb84 100644 --- a/graphql_server/test/query_test.dart +++ b/graphql_server/test/query_test.dart @@ -21,7 +21,7 @@ void main() { queryType: objectType('api', fields: [ field( 'todos', - listType(todoType), + listOf(todoType), resolve: (_, __) => [ new Todo( text: 'Clean your room!',