From e31e8412e954d8cb28efeed1fa5fd4859094dcff Mon Sep 17 00:00:00 2001 From: Dane Pilcher Date: Wed, 11 Oct 2023 11:35:42 -0600 Subject: [PATCH] test: multi dimensional array TS type --- .../test/fixtures/misc/schema.graphql | 16 + .../test/fixtures/misc/schema.json | 969 ++++++++++++------ .../__snapshots__/codeGeneration.js.snap | 25 + .../test/typescript/codeGeneration.js | 13 + 4 files changed, 712 insertions(+), 311 deletions(-) diff --git a/packages/graphql-types-generator/test/fixtures/misc/schema.graphql b/packages/graphql-types-generator/test/fixtures/misc/schema.graphql index 1bc5c3aad..8ea9a2283 100644 --- a/packages/graphql-types-generator/test/fixtures/misc/schema.graphql +++ b/packages/graphql-types-generator/test/fixtures/misc/schema.graphql @@ -64,8 +64,24 @@ type Query { scalarTest: Boolean! arrayTest: [QueryObject] echo(msg: String): String + multiDimensionalArrayTest: MultiDimensionalArrayTest } type QueryObject { test: String } + +type MultiDimensionalArrayTest { + id: ID! + name: String! + abc: ABC +} + +type XYZ { + id: ID! + name: String! +} + +type ABC { + abc: [[XYZ]] +} diff --git a/packages/graphql-types-generator/test/fixtures/misc/schema.json b/packages/graphql-types-generator/test/fixtures/misc/schema.json index c0ead38ef..b4fc8bbc4 100644 --- a/packages/graphql-types-generator/test/fixtures/misc/schema.json +++ b/packages/graphql-types-generator/test/fixtures/misc/schema.json @@ -1,20 +1,412 @@ { "data": { "__schema": { + "description": null, "queryType": { "name": "Query" }, "mutationType": null, "subscriptionType": null, "types": [ + { + "kind": "SCALAR", + "name": "Date", + "description": null, + "specifiedByURL": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "doubleHump", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "humpOne", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "humpTwo", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "String", + "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", + "specifiedByURL": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "OddType", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "date", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "Date", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "camel", + "description": null, + "args": [], + "type": { + "kind": "OBJECT", + "name": "doubleHump", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "CommentTest", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "singleLine", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "multiLine", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "enumCommentTest", + "description": null, + "args": [], + "type": { + "kind": "ENUM", + "name": "EnumCommentTestCase", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "ENUM", + "name": "EnumCommentTestCase", + "description": null, + "specifiedByURL": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "first", + "description": null, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "second", + "description": null, + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, + { + "kind": "INTERFACE", + "name": "InterfaceTestCase", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "prop", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": [ + { + "kind": "OBJECT", + "name": "ImplA", + "ofType": null + }, + { + "kind": "OBJECT", + "name": "ImplB", + "ofType": null + } + ] + }, + { + "kind": "OBJECT", + "name": "ImplA", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "prop", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "propA", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [ + { + "kind": "INTERFACE", + "name": "InterfaceTestCase", + "ofType": null + } + ], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "ImplB", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "prop", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "propB", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [ + { + "kind": "INTERFACE", + "name": "InterfaceTestCase", + "ofType": null + } + ], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "SCALAR", + "name": "Int", + "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.", + "specifiedByURL": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "PartialA", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "prop", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "OBJECT", + "name": "PartialB", + "description": null, + "specifiedByURL": null, + "fields": [ + { + "name": "prop", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + } + ], + "inputFields": null, + "interfaces": [], + "enumValues": null, + "possibleTypes": null + }, + { + "kind": "UNION", + "name": "UnionTestCase", + "description": null, + "specifiedByURL": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": null, + "possibleTypes": [ + { + "kind": "OBJECT", + "name": "PartialA", + "ofType": null + }, + { + "kind": "OBJECT", + "name": "PartialB", + "ofType": null + } + ] + }, { "kind": "OBJECT", "name": "Query", - "description": "", + "description": null, + "specifiedByURL": null, "fields": [ { "name": "misc", - "description": "", + "description": null, "args": [], "type": { "kind": "OBJECT", @@ -26,7 +418,7 @@ }, { "name": "commentTest", - "description": "", + "description": null, "args": [], "type": { "kind": "OBJECT", @@ -38,7 +430,7 @@ }, { "name": "interfaceTest", - "description": "", + "description": null, "args": [], "type": { "kind": "INTERFACE", @@ -50,7 +442,7 @@ }, { "name": "unionTest", - "description": "", + "description": null, "args": [], "type": { "kind": "UNION", @@ -62,7 +454,7 @@ }, { "name": "scalarTest", - "description": "", + "description": null, "args": [], "type": { "kind": "NON_NULL", @@ -94,17 +486,19 @@ }, { "name": "echo", - "description": "", + "description": null, "args": [ { "name": "msg", - "description": "", + "description": null, "type": { "kind": "SCALAR", "name": "String", "ofType": null }, - "defaultValue": null + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ], "type": { @@ -114,60 +508,14 @@ }, "isDeprecated": false, "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "QueryObject", - "description": null, - "fields": [ - { - "name": "test", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "OddType", - "description": "", - "fields": [ - { - "name": "date", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null }, { - "name": "camel", - "description": "", + "name": "multiDimensionalArrayTest", + "description": null, "args": [], "type": { "kind": "OBJECT", - "name": "doubleHump", + "name": "MultiDimensionalArrayTest", "ofType": null }, "isDeprecated": false, @@ -181,8 +529,9 @@ }, { "kind": "SCALAR", - "name": "Date", - "description": "", + "name": "Boolean", + "description": "The `Boolean` scalar type represents `true` or `false`.", + "specifiedByURL": null, "fields": null, "inputFields": null, "interfaces": null, @@ -191,24 +540,13 @@ }, { "kind": "OBJECT", - "name": "doubleHump", - "description": "", + "name": "QueryObject", + "description": null, + "specifiedByURL": null, "fields": [ { - "name": "humpOne", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "humpTwo", - "description": "", + "name": "test", + "description": null, "args": [], "type": { "kind": "SCALAR", @@ -224,52 +562,51 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "SCALAR", - "name": "String", - "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", - "name": "CommentTest", - "description": "This is a type to test comments", + "name": "MultiDimensionalArrayTest", + "description": null, + "specifiedByURL": null, "fields": [ { - "name": "singleLine", - "description": "This is a single-line comment", + "name": "id", + "description": null, "args": [], "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null }, { - "name": "multiLine", - "description": "This is a multi-line\ncomment.", + "name": "name", + "description": null, "args": [], "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, "isDeprecated": false, "deprecationReason": null }, { - "name": "enumCommentTest", - "description": "", + "name": "abc", + "description": null, "args": [], "type": { - "kind": "ENUM", - "name": "EnumCommentTestCase", + "kind": "OBJECT", + "name": "ABC", "ofType": null }, "isDeprecated": false, @@ -282,95 +619,41 @@ "possibleTypes": null }, { - "kind": "ENUM", - "name": "EnumCommentTestCase", - "description": "", + "kind": "SCALAR", + "name": "ID", + "description": "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.", + "specifiedByURL": null, "fields": null, "inputFields": null, "interfaces": null, - "enumValues": [ - { - "name": "first", - "description": "This is a single-line comment", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "second", - "description": "This is a multi-line\ncomment.", - "isDeprecated": false, - "deprecationReason": null - } - ], + "enumValues": null, "possibleTypes": null }, { - "kind": "INTERFACE", - "name": "InterfaceTestCase", - "description": "", + "kind": "OBJECT", + "name": "XYZ", + "description": null, + "specifiedByURL": null, "fields": [ { - "name": "prop", - "description": "", + "name": "id", + "description": null, "args": [], "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "ID", "ofType": null } }, "isDeprecated": false, "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "ImplA", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "ImplB", - "ofType": null - } - ] - }, - { - "kind": "UNION", - "name": "UnionTestCase", - "description": "", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "PartialA", - "ofType": null }, { - "kind": "OBJECT", - "name": "PartialB", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "PartialA", - "description": "", - "fields": [ - { - "name": "prop", - "description": "", + "name": "name", + "description": null, "args": [], "type": { "kind": "NON_NULL", @@ -392,20 +675,25 @@ }, { "kind": "OBJECT", - "name": "PartialB", - "description": "", + "name": "ABC", + "description": null, + "specifiedByURL": null, "fields": [ { - "name": "prop", - "description": "", + "name": "abc", + "description": null, "args": [], "type": { - "kind": "NON_NULL", + "kind": "LIST", "name": null, "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "LIST", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "XYZ", + "ofType": null + } } }, "isDeprecated": false, @@ -417,21 +705,24 @@ "enumValues": null, "possibleTypes": null }, - { - "kind": "SCALAR", - "name": "Boolean", - "description": "The `Boolean` scalar type represents `true` or `false`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, { "kind": "OBJECT", "name": "__Schema", "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", + "specifiedByURL": null, "fields": [ + { + "name": "description", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "types", "description": "A list of all types supported by this server.", @@ -529,7 +820,8 @@ { "kind": "OBJECT", "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", + "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", + "specifiedByURL": null, "fields": [ { "name": "kind", @@ -571,6 +863,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "specifiedByURL", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "fields", "description": null, @@ -583,7 +887,9 @@ "name": "Boolean", "ofType": null }, - "defaultValue": "false" + "defaultValue": "false", + "isDeprecated": false, + "deprecationReason": null } ], "type": { @@ -654,7 +960,9 @@ "name": "Boolean", "ofType": null }, - "defaultValue": "false" + "defaultValue": "false", + "isDeprecated": false, + "deprecationReason": null } ], "type": { @@ -676,7 +984,20 @@ { "name": "inputFields", "description": null, - "args": [], + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false", + "isDeprecated": false, + "deprecationReason": null + } + ], "type": { "kind": "LIST", "name": null, @@ -715,6 +1036,7 @@ "kind": "ENUM", "name": "__TypeKind", "description": "An enum describing what kind of type a given `__Type` is.", + "specifiedByURL": null, "fields": null, "inputFields": null, "interfaces": null, @@ -733,7 +1055,7 @@ }, { "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", + "description": "Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.", "isDeprecated": false, "deprecationReason": null }, @@ -774,6 +1096,7 @@ "kind": "OBJECT", "name": "__Field", "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", + "specifiedByURL": null, "fields": [ { "name": "name", @@ -806,7 +1129,20 @@ { "name": "args", "description": null, - "args": [], + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false", + "isDeprecated": false, + "deprecationReason": null + } + ], "type": { "kind": "NON_NULL", "name": null, @@ -881,6 +1217,7 @@ "kind": "OBJECT", "name": "__InputValue", "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", + "specifiedByURL": null, "fields": [ { "name": "name", @@ -937,6 +1274,34 @@ }, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "isDeprecated", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "deprecationReason", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null } ], "inputFields": null, @@ -948,6 +1313,7 @@ "kind": "OBJECT", "name": "__EnumValue", "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", + "specifiedByURL": null, "fields": [ { "name": "name", @@ -1015,6 +1381,7 @@ "kind": "OBJECT", "name": "__Directive", "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + "specifiedByURL": null, "fields": [ { "name": "name", @@ -1044,6 +1411,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "isRepeatable", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "locations", "description": null, @@ -1071,7 +1454,20 @@ { "name": "args", "description": null, - "args": [], + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false", + "isDeprecated": false, + "deprecationReason": null + } + ], "type": { "kind": "NON_NULL", "name": null, @@ -1102,6 +1498,7 @@ "kind": "ENUM", "name": "__DirectiveLocation", "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", + "specifiedByURL": null, "fields": null, "inputFields": null, "interfaces": null, @@ -1148,6 +1545,12 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "VARIABLE_DEFINITION", + "description": "Location adjacent to a variable definition.", + "isDeprecated": false, + "deprecationReason": null + }, { "name": "SCHEMA", "description": "Location adjacent to a schema definition.", @@ -1216,117 +1619,46 @@ } ], "possibleTypes": null - }, + } + ], + "directives": [ { - "kind": "OBJECT", - "name": "ImplA", - "description": "", - "fields": [ - { - "name": "prop", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "propA", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "InterfaceTestCase", - "ofType": null - } + "name": "include", + "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", + "isRepeatable": false, + "locations": [ + "FIELD", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "ImplB", - "description": "", - "fields": [ + "args": [ { - "name": "prop", - "description": "", - "args": [], + "name": "if", + "description": "Included when true.", "type": { "kind": "NON_NULL", "name": null, "ofType": { "kind": "SCALAR", - "name": "String", + "name": "Boolean", "ofType": null } }, + "defaultValue": null, "isDeprecated": false, "deprecationReason": null - }, - { - "name": "propB", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "InterfaceTestCase", - "ofType": null } - ], - "enumValues": null, - "possibleTypes": null + ] }, - { - "kind": "SCALAR", - "name": "Int", - "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - } - ], - "directives": [ { "name": "skip", "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], + "isRepeatable": false, + "locations": [ + "FIELD", + "FRAGMENT_SPREAD", + "INLINE_FRAGMENT" + ], "args": [ { "name": "if", @@ -1340,45 +1672,60 @@ "ofType": null } }, - "defaultValue": null + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ] }, { - "name": "include", - "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], + "name": "deprecated", + "description": "Marks an element of a GraphQL schema as no longer supported.", + "isRepeatable": false, + "locations": [ + "FIELD_DEFINITION", + "ARGUMENT_DEFINITION", + "INPUT_FIELD_DEFINITION", + "ENUM_VALUE" + ], "args": [ { - "name": "if", - "description": "Included when true.", + "name": "reason", + "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).", "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } + "kind": "SCALAR", + "name": "String", + "ofType": null }, - "defaultValue": null + "defaultValue": "\"No longer supported\"", + "isDeprecated": false, + "deprecationReason": null } ] }, { - "name": "deprecated", - "description": "Marks an element of a GraphQL schema as no longer supported.", - "locations": ["FIELD_DEFINITION", "ENUM_VALUE"], + "name": "specifiedBy", + "description": "Exposes a URL that specifies the behavior of this scalar.", + "isRepeatable": false, + "locations": [ + "SCALAR" + ], "args": [ { - "name": "reason", - "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", + "name": "url", + "description": "The URL that specifies the behavior of this scalar.", "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } }, - "defaultValue": "\"No longer supported\"" + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null } ] } diff --git a/packages/graphql-types-generator/test/typescript/__snapshots__/codeGeneration.js.snap b/packages/graphql-types-generator/test/typescript/__snapshots__/codeGeneration.js.snap index 97d14062e..36ab4df2c 100644 --- a/packages/graphql-types-generator/test/typescript/__snapshots__/codeGeneration.js.snap +++ b/packages/graphql-types-generator/test/typescript/__snapshots__/codeGeneration.js.snap @@ -1517,3 +1517,28 @@ export type starshipDetailsFragment = { }; " `; + +exports[`TypeScript code generation #generateSource() two dimensional array of non-model type 1`] = ` +"/* tslint:disable */ +/* eslint-disable */ +// This file was automatically generated and should not be edited. + +export type MultiDimensionalArrayTest = { + __typename: \\"MultiDimensionalArrayTest\\", + id: string, + name: string, + abc?: ABC | null, +}; + +export type ABC = { + __typename: \\"ABC\\", + abc?: Array> | null, +}; + +export type XYZ = { + __typename: \\"XYZ\\", + id: string, + name: string, +}; +" +`; diff --git a/packages/graphql-types-generator/test/typescript/codeGeneration.js b/packages/graphql-types-generator/test/typescript/codeGeneration.js index 26e2b1430..00015e877 100644 --- a/packages/graphql-types-generator/test/typescript/codeGeneration.js +++ b/packages/graphql-types-generator/test/typescript/codeGeneration.js @@ -327,5 +327,18 @@ describe('TypeScript code generation', function() { const source = generateSource(context); expect(source).toMatchSnapshot(); }); + + test.only('two dimensional array of non-model type', () => { + const { compileFromSource } = setup(miscSchema); + const context = compileFromSource(` + query MultiTest { + multiDimensionalArrayTest { + abc + } + } + `); + const source = generateSource(context); + expect(source).toMatchSnapshot(); + }); }); });