@@ -32,7 +32,7 @@ const getGQLv2Visitor = (
3232 return visitor ;
3333} ;
3434
35- describe ( 'AppSyncSwiftVisitor - GQLv2 Regression Tests' , ( ) => {
35+ describe ( 'AppSyncJavaVisitor - GQLv2 Regression Tests' , ( ) => {
3636 it ( 'Works when configuring a secondary index' , ( ) => {
3737 const schema = /* GraphQL */ `
3838 type Customer @model {
@@ -52,7 +52,7 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
5252 expect ( getGQLv2Visitor ( schema , 'Todo' ) . generate ( ) ) . toMatchSnapshot ( ) ;
5353 } ) ;
5454
55- it ( 'Works on has one relationship @hasOne' , ( ) => {
55+ it ( 'Works on uni-directional implicit has one relationship @hasOne' , ( ) => {
5656 const schema = /* GraphQL */ `
5757 # Implicit field
5858 type Project @model {
@@ -65,7 +65,13 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
6565 id: ID!
6666 name: String!
6767 }
68+ ` ;
69+ expect ( getGQLv2Visitor ( schema , 'Project' ) . generate ( ) ) . toMatchSnapshot ( ) ;
70+ expect ( getGQLv2Visitor ( schema , 'Team' ) . generate ( ) ) . toMatchSnapshot ( ) ;
71+ } ) ;
6872
73+ it ( 'Works on uni-directional explicit has one relationship @hasOne' , ( ) => {
74+ const schema = /* GraphQL */ `
6975 # Explicit field
7076 type Project2 @model {
7177 id: ID!
@@ -79,13 +85,11 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
7985 name: String!
8086 }
8187 ` ;
82- expect ( getGQLv2Visitor ( schema , 'Project' ) . generate ( ) ) . toMatchSnapshot ( ) ;
83- expect ( getGQLv2Visitor ( schema , 'Team' ) . generate ( ) ) . toMatchSnapshot ( ) ;
8488 expect ( getGQLv2Visitor ( schema , 'Project2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
8589 expect ( getGQLv2Visitor ( schema , 'Team2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
8690 } ) ;
8791
88- it ( 'Works on has many relationship @hasMany' , ( ) => {
92+ it ( 'Works on uni-directional implicit has many relationship @hasMany' , ( ) => {
8993 const schema = /* GraphQL */ `
9094 # Implicit
9195 type Post @model {
@@ -98,7 +102,13 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
98102 id: ID!
99103 content: String!
100104 }
105+ ` ;
106+ expect ( getGQLv2Visitor ( schema , 'Post' ) . generate ( ) ) . toMatchSnapshot ( ) ;
107+ expect ( getGQLv2Visitor ( schema , 'Comment' ) . generate ( ) ) . toMatchSnapshot ( ) ;
108+ } ) ;
101109
110+ it ( 'Works on uni-directional explicit has many relationship @hasMany' , ( ) => {
111+ const schema = /* GraphQL */ `
102112 # Explicit
103113 type Post2 @model {
104114 id: ID!
@@ -112,8 +122,6 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
112122 content: String!
113123 }
114124 ` ;
115- expect ( getGQLv2Visitor ( schema , 'Post' ) . generate ( ) ) . toMatchSnapshot ( ) ;
116- expect ( getGQLv2Visitor ( schema , 'Comment' ) . generate ( ) ) . toMatchSnapshot ( ) ;
117125 expect ( getGQLv2Visitor ( schema , 'Post2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
118126 expect ( getGQLv2Visitor ( schema , 'Comment2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
119127 } ) ;
@@ -137,7 +145,7 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
137145 expect ( getGQLv2Visitor ( schema , 'Tag' ) . generate ( ) ) . toMatchSnapshot ( ) ;
138146 } ) ;
139147
140- it ( 'Works on belongs to relationship @belongsTo' , ( ) => {
148+ it ( 'Works on implicit hasOne belongs to relationship @belongsTo' , ( ) => {
141149 const schema = /* GraphQL */ `
142150 # Implicit
143151 type Project @model {
@@ -151,7 +159,13 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
151159 name: String!
152160 project: Project @belongsTo
153161 }
162+ ` ;
163+ expect ( getGQLv2Visitor ( schema , 'Project' ) . generate ( ) ) . toMatchSnapshot ( ) ;
164+ expect ( getGQLv2Visitor ( schema , 'Team' ) . generate ( ) ) . toMatchSnapshot ( ) ;
165+ } ) ;
154166
167+ it ( 'Works on explicit hasOne belongs to relationship @belongsTo' , ( ) => {
168+ const schema = /* GraphQL */ `
155169 # Explicit
156170 type Project2 @model {
157171 id: ID!
@@ -165,7 +179,13 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
165179 projectID: ID
166180 project: Project2 @belongsTo(fields: ["projectID"])
167181 }
182+ ` ;
183+ expect ( getGQLv2Visitor ( schema , 'Project2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
184+ expect ( getGQLv2Visitor ( schema , 'Team2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
185+ } ) ;
168186
187+ it ( 'Works on explicit hasMany belongs to relationship @belongsTo' , ( ) => {
188+ const schema = /* GraphQL */ `
169189 # Explicit - Bi-directional Has Many
170190 type Post @model {
171191 id: ID!
@@ -180,15 +200,12 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
180200 post: Post @belongsTo(fields: ["postID"])
181201 }
182202 ` ;
183- expect ( getGQLv2Visitor ( schema , 'Project' ) . generate ( ) ) . toMatchSnapshot ( ) ;
184- expect ( getGQLv2Visitor ( schema , 'Team' ) . generate ( ) ) . toMatchSnapshot ( ) ;
185- expect ( getGQLv2Visitor ( schema , 'Project2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
186- expect ( getGQLv2Visitor ( schema , 'Team2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
187203 expect ( getGQLv2Visitor ( schema , 'Post' ) . generate ( ) ) . toMatchSnapshot ( ) ;
188204 expect ( getGQLv2Visitor ( schema , 'Comment' ) . generate ( ) ) . toMatchSnapshot ( ) ;
189205 } ) ;
190206
191- it ( 'Works on belongs to relationship @belongsTo (extended)' , ( ) => {
207+
208+ it ( 'Works on implicit hasMany belongs to relationship @belongsTo (extended)' , ( ) => {
192209 const schema = /* GraphQL */ `
193210 # 7 - Blog Post Comment
194211 type Blog7V2 @model {
@@ -210,62 +227,6 @@ describe('AppSyncSwiftVisitor - GQLv2 Regression Tests', () => {
210227 ` ;
211228 expect ( getGQLv2Visitor ( schema , 'Blog7V2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
212229 expect ( getGQLv2Visitor ( schema , 'Post7V2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
213- expect ( getGQLv2Visitor ( schema , 'Project2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
214230 expect ( getGQLv2Visitor ( schema , 'Comment7V2' ) . generate ( ) ) . toMatchSnapshot ( ) ;
215231 } ) ;
216-
217- it ( 'scenario 9 - Implicit Belongs to Relationship' , ( ) => {
218- const schema = /* GraphQL */ `
219- type Project @model {
220- id: ID!
221- name: String
222- team: Team @hasOne
223- }
224-
225- type Team @model {
226- id: ID!
227- name: String!
228- project: Project @belongsTo
229- }
230- ` ;
231- expect ( getGQLv2Visitor ( schema , 'Project' ) . generate ( ) ) . toMatchSnapshot ( ) ;
232- expect ( getGQLv2Visitor ( schema , 'Team' ) . generate ( ) ) . toMatchSnapshot ( ) ;
233- } ) ;
234-
235- it ( 'scenario 10 - Explicit Belongs to Relationship' , ( ) => {
236- const schema = /* GraphQL */ `
237- type Project @model {
238- id: ID!
239- name: String
240- team: Team @hasOne
241- }
242-
243- type Team @model {
244- id: ID!
245- name: String!
246- projectID: ID
247- project: Project @belongsTo(fields: ["projectID"])
248- }
249- ` ;
250- expect ( getGQLv2Visitor ( schema , 'Project' ) . generate ( ) ) . toMatchSnapshot ( ) ;
251- expect ( getGQLv2Visitor ( schema , 'Team' ) . generate ( ) ) . toMatchSnapshot ( ) ;
252- } ) ;
253-
254- it ( 'scenario 12 - Belongs to Relationship field and type names don’t align' , ( ) => {
255- const schema = /* GraphQL */ `
256- type CookingBlog @model {
257- id: ID!
258- name: String!
259- posts: [RecipePost] @hasMany
260- }
261-
262- type RecipePost @model {
263- id: ID!
264- title: String!
265- blog: CookingBlog @belongsTo
266- }
267- ` ;
268- expect ( getGQLv2Visitor ( schema , 'CookingBlog' ) . generate ( ) ) . toMatchSnapshot ( ) ;
269- expect ( getGQLv2Visitor ( schema , 'RecipePost' ) . generate ( ) ) . toMatchSnapshot ( ) ;
270- } ) ;
271232} ) ;
0 commit comments