Skip to content

Commit

Permalink
Basic middleware system (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie authored Jun 25, 2024
2 parents 3c5e94f + 8d238a6 commit 7e2912c
Show file tree
Hide file tree
Showing 14 changed files with 761 additions and 172 deletions.
18 changes: 9 additions & 9 deletions __tests__/depth-limit-basics/output.ansi
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
FoFoF_fragments.graphql:
- Self-reference limit for field 'User.friends' exceeded: 3 > 2
- [17:3] Self-reference limit for field 'User.friends' exceeded: 3 > 2
Problematic paths:
- FoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends

FoFoF.graphql:
- Self-reference limit for field 'User.friends' exceeded: 3 > 2
- [6:9] Self-reference limit for field 'User.friends' exceeded: 3 > 2
Problematic paths:
- FoFoF:query>currentUser>friends>friends>friends

FoFoFoF_fragments.graphql:
- Self-reference limit for field 'User.friends' exceeded: 4 > 3
- [22:3] Self-reference limit for field 'User.friends' exceeded: 4 > 3
Problematic paths:
- FoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends

FoFoFoF.graphql:
- Self-reference limit for field 'User.friends' exceeded: 4 > 3
- [7:11] Self-reference limit for field 'User.friends' exceeded: 4 > 3
Problematic paths:
- FoFoFoF:query>currentUser>friends>friends>friends>friends

FoFoFoFoFoF_fragments.graphql:
- Maximum list nesting depth limit exceeded: 6 > 5
- [35:3] Maximum list nesting depth limit exceeded: 6 > 5
Problematic paths:
- FoFoFoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends>F5:User.friends>F6:User.friends

FoFoFoFoFoF.graphql:
- Maximum list nesting depth limit exceeded: 6 > 5
- [9:15] Maximum list nesting depth limit exceeded: 6 > 5
Problematic paths:
- FoFoFoFoFoF:query>currentUser>friends>friends>friends>friends>friends>friends

Expand All @@ -41,16 +41,16 @@ Invalid_FoFoFoFoF_wide_cycle.graphql:
- [9:5] Cannot spread fragment "F1" within itself via "F2", "F3", "F4", "F5".

Self10_fragments.graphql:
- Maximum selection depth limit exceeded: 11 > 10
- [49:3] Maximum selection depth limit exceeded: 11 > 10
Problematic paths:
- Self10:query>currentUser>self>F1:User.self>F2:User.self>F3:User.self>F4:User.self>F5:User.self>F6:User.self>F7:User.self>F8:User.self>F9:User.self

Self10.graphql:
- Maximum selection depth limit exceeded: 11 > 10
- [13:23] Maximum selection depth limit exceeded: 11 > 10
Problematic paths:
- Self10:query>currentUser>self>self>self>self>self>self>self>self>self>self

SelfOtherSelf5.graphql:
- Maximum selection depth limit exceeded: 11 > 10
- [13:23] Maximum selection depth limit exceeded: 11 > 10
Problematic paths:
- SelfOtherSelf5:query>currentUser>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf
16 changes: 8 additions & 8 deletions __tests__/depth-limit-basics/output.custom-baseline.ansi
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
FoFoF.graphql:
- Self-reference limit for field 'User.friends' exceeded: 3 > 2
- [6:9] Self-reference limit for field 'User.friends' exceeded: 3 > 2
Problematic paths:
- FoFoF:query>currentUser>friends>friends>friends

FoFoFoF_fragments.graphql:
- Self-reference limit for field 'User.friends' exceeded: 4 > 3
- [22:3] Self-reference limit for field 'User.friends' exceeded: 4 > 3
Problematic paths:
- FoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends

FoFoFoF.graphql:
- Self-reference limit for field 'User.friends' exceeded: 4 > 3
- [7:11] Self-reference limit for field 'User.friends' exceeded: 4 > 3
Problematic paths:
- FoFoFoF:query>currentUser>friends>friends>friends>friends

FoFoFoFoFoF_fragments.graphql:
- Maximum list nesting depth limit exceeded: 6 > 5
- [35:3] Maximum list nesting depth limit exceeded: 6 > 5
Problematic paths:
- FoFoFoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends>F5:User.friends>F6:User.friends

FoFoFoFoFoF.graphql:
- Maximum list nesting depth limit exceeded: 6 > 5
- [9:15] Maximum list nesting depth limit exceeded: 6 > 5
Problematic paths:
- FoFoFoFoFoF:query>currentUser>friends>friends>friends>friends>friends>friends

Expand All @@ -36,16 +36,16 @@ Invalid_FoFoFoFoF_wide_cycle.graphql:
- [9:5] Cannot spread fragment "F1" within itself via "F2", "F3", "F4", "F5".

Self10_fragments.graphql:
- Maximum selection depth limit exceeded: 11 > 10
- [49:3] Maximum selection depth limit exceeded: 11 > 10
Problematic paths:
- Self10:query>currentUser>self>F1:User.self>F2:User.self>F3:User.self>F4:User.self>F5:User.self>F6:User.self>F7:User.self>F8:User.self>F9:User.self

Self10.graphql:
- Maximum selection depth limit exceeded: 11 > 10
- [13:23] Maximum selection depth limit exceeded: 11 > 10
Problematic paths:
- Self10:query>currentUser>self>self>self>self>self>self>self>self>self>self

SelfOtherSelf5.graphql:
- Maximum selection depth limit exceeded: 11 > 10
- [13:23] Maximum selection depth limit exceeded: 11 > 10
Problematic paths:
- SelfOtherSelf5:query>currentUser>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf
128 changes: 104 additions & 24 deletions __tests__/depth-limit-basics/results.custom-baseline.json5
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@
errors: [
{
message: "Self-reference limit for field 'User.friends' exceeded: 3 > 2",
locations: [
{
line: 6,
column: 9,
},
],
infraction: "maxDepthByFieldCoordinates['User.friends']",
operationName: 'FoFoF',
operationCoordinates: [
'FoFoF:query>currentUser>friends>friends>friends',
operations: [
{
operationName: 'FoFoF',
operationCoordinates: [
'FoFoF:query>currentUser>friends>friends>friends',
],
},
],
override: {
maxDepthByFieldCoordinates: {
Expand All @@ -55,10 +65,20 @@
errors: [
{
message: "Self-reference limit for field 'User.friends' exceeded: 4 > 3",
locations: [
{
line: 22,
column: 3,
},
],
infraction: "maxDepthByFieldCoordinates['User.friends']",
operationName: 'FoFoFoF',
operationCoordinates: [
'FoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends',
operations: [
{
operationName: 'FoFoFoF',
operationCoordinates: [
'FoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends',
],
},
],
override: {
maxDepthByFieldCoordinates: {
Expand All @@ -81,10 +101,20 @@
errors: [
{
message: "Self-reference limit for field 'User.friends' exceeded: 4 > 3",
locations: [
{
line: 7,
column: 11,
},
],
infraction: "maxDepthByFieldCoordinates['User.friends']",
operationName: 'FoFoFoF',
operationCoordinates: [
'FoFoFoF:query>currentUser>friends>friends>friends>friends',
operations: [
{
operationName: 'FoFoFoF',
operationCoordinates: [
'FoFoFoF:query>currentUser>friends>friends>friends>friends',
],
},
],
override: {
maxDepthByFieldCoordinates: {
Expand Down Expand Up @@ -131,10 +161,20 @@
errors: [
{
message: 'Maximum list nesting depth limit exceeded: 6 > 5',
locations: [
{
line: 35,
column: 3,
},
],
infraction: 'maxListDepth',
operationName: 'FoFoFoFoFoF',
operationCoordinates: [
'FoFoFoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends>F5:User.friends>F6:User.friends',
operations: [
{
operationName: 'FoFoFoFoFoF',
operationCoordinates: [
'FoFoFoFoFoF:query>currentUser>F1:User.friends>F2:User.friends>F3:User.friends>F4:User.friends>F5:User.friends>F6:User.friends',
],
},
],
override: {
maxListDepth: 6,
Expand All @@ -155,10 +195,20 @@
errors: [
{
message: 'Maximum list nesting depth limit exceeded: 6 > 5',
locations: [
{
line: 9,
column: 15,
},
],
infraction: 'maxListDepth',
operationName: 'FoFoFoFoFoF',
operationCoordinates: [
'FoFoFoFoFoF:query>currentUser>friends>friends>friends>friends>friends>friends',
operations: [
{
operationName: 'FoFoFoFoFoF',
operationCoordinates: [
'FoFoFoFoFoF:query>currentUser>friends>friends>friends>friends>friends>friends',
],
},
],
override: {
maxListDepth: 6,
Expand Down Expand Up @@ -263,10 +313,20 @@
errors: [
{
message: 'Maximum selection depth limit exceeded: 11 > 10',
locations: [
{
line: 49,
column: 3,
},
],
infraction: 'maxDepth',
operationName: 'Self10',
operationCoordinates: [
'Self10:query>currentUser>self>F1:User.self>F2:User.self>F3:User.self>F4:User.self>F5:User.self>F6:User.self>F7:User.self>F8:User.self>F9:User.self',
operations: [
{
operationName: 'Self10',
operationCoordinates: [
'Self10:query>currentUser>self>F1:User.self>F2:User.self>F3:User.self>F4:User.self>F5:User.self>F6:User.self>F7:User.self>F8:User.self>F9:User.self',
],
},
],
override: {
maxDepth: 11,
Expand All @@ -287,10 +347,20 @@
errors: [
{
message: 'Maximum selection depth limit exceeded: 11 > 10',
locations: [
{
line: 13,
column: 23,
},
],
infraction: 'maxDepth',
operationName: 'Self10',
operationCoordinates: [
'Self10:query>currentUser>self>self>self>self>self>self>self>self>self>self',
operations: [
{
operationName: 'Self10',
operationCoordinates: [
'Self10:query>currentUser>self>self>self>self>self>self>self>self>self>self',
],
},
],
override: {
maxDepth: 11,
Expand Down Expand Up @@ -335,10 +405,20 @@
errors: [
{
message: 'Maximum selection depth limit exceeded: 11 > 10',
locations: [
{
line: 13,
column: 23,
},
],
infraction: 'maxDepth',
operationName: 'SelfOtherSelf5',
operationCoordinates: [
'SelfOtherSelf5:query>currentUser>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf',
operations: [
{
operationName: 'SelfOtherSelf5',
operationCoordinates: [
'SelfOtherSelf5:query>currentUser>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf>self>otherSelf',
],
},
],
override: {
maxDepth: 11,
Expand Down
Loading

0 comments on commit 7e2912c

Please sign in to comment.