Last active
April 3, 2021 12:36
-
-
Save vladar/3fbc37d2f5fc3dd84f8b40393e43f906 to your computer and use it in GitHub Desktop.
Dynamic nested connections in GraphQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const query = graphql` | |
{ | |
allFoo(filter: { foo: { eq: "foo" }}) { | |
nodes { | |
id | |
foo | |
fooBars @connect(field: "allBar", filter: { fooId: { eq: this__id } }) { | |
nodes { | |
bar | |
} | |
} | |
} | |
} | |
} | |
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const query = graphql` | |
{ | |
allFoo(filter: { foo: { eq: "foo" }}) { | |
nodes { | |
id | |
foo | |
connect { | |
# A bit more verbose but fully GraphQL-compliant with autocomplete, etc | |
fooBars: allBars(filter: { fooId: { eq: this__id } }) { | |
nodes { | |
bar | |
} | |
} | |
} | |
} | |
} | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment