@@ -105,6 +105,111 @@ describe('policy checks', () => {
105105 ` ) ;
106106 } ) ;
107107
108+ it ( 'refreshes edge types per run' , async ( ) => {
109+ const caller = schemaPolicyApiRouter . createCaller ( { req : { log : console } as any } ) ;
110+ const userSchema = `
111+ type Query {
112+ # 'first' limits results; 'after' is the cursor to start from
113+ users(first: Int, after: String): UserConnection!
114+ }
115+
116+ type UserConnection {
117+ edges: [UserEdge!]!
118+ pageInfo: PageInfo!
119+ totalCount: Int!
120+ }
121+
122+ type UserEdge {
123+ node: User!
124+ cursor: String!
125+ }
126+
127+ type PageInfo {
128+ hasNextPage: Boolean!
129+ endCursor: String
130+ }
131+
132+ interface Node {
133+ id: ID!
134+ }
135+
136+ type User {
137+ id: ID!
138+ name: String!
139+ }
140+ ` ;
141+ const result = await caller . checkPolicy ( {
142+ source : userSchema ,
143+ schema : userSchema ,
144+ target : '1' ,
145+ policy : {
146+ 'relay-edge-types' : [
147+ 2 ,
148+ {
149+ withEdgeSuffix : true ,
150+ shouldImplementNode : true ,
151+ listTypeCanWrapOnlyEdgeType : false ,
152+ } ,
153+ ] ,
154+ } ,
155+ } ) ;
156+
157+ expect ( result . length ) . toBe ( 1 ) ;
158+ expect ( result [ 0 ] . message ) . toBe ( "Edge type's field \`node\` must implement \`Node\` interface." ) ;
159+
160+ const noUserSchema = `
161+ type Query {
162+ # 'first' limits results; 'after' is the cursor to start from
163+ noUsers(first: Int, after: String): NoUserConnection!
164+ }
165+
166+ type NoUserConnection {
167+ edges: [NoUserEdge!]!
168+ pageInfo: PageInfo!
169+ totalCount: Int!
170+ }
171+
172+ type NoUserEdge {
173+ node: NoUser!
174+ cursor: String!
175+ }
176+
177+ type PageInfo {
178+ hasNextPage: Boolean!
179+ endCursor: String
180+ }
181+
182+ interface Node {
183+ id: ID!
184+ }
185+
186+ type NoUser {
187+ id: ID!
188+ name: String!
189+ }
190+ ` ;
191+ const noUserResult = await caller . checkPolicy ( {
192+ source : noUserSchema ,
193+ schema : noUserSchema ,
194+ target : '1' ,
195+ policy : {
196+ 'relay-edge-types' : [
197+ 2 ,
198+ {
199+ withEdgeSuffix : true ,
200+ shouldImplementNode : true ,
201+ listTypeCanWrapOnlyEdgeType : false ,
202+ } ,
203+ ] ,
204+ } ,
205+ } ) ;
206+
207+ expect ( noUserResult . length ) . toBe ( 1 ) ;
208+ expect ( noUserResult [ 0 ] . message ) . toBe (
209+ "Edge type's field \`node\` must implement \`Node\` interface." ,
210+ ) ;
211+ } ) ;
212+
108213 /** To ensure existing policies dont break during upgrades */
109214 it . each ( policies ) ( 'should support existing policies' , async policy => {
110215 await expect (
0 commit comments