Skip to content

Instantly share code, notes, and snippets.

@vladar
Last active April 3, 2021 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vladar/3fbc37d2f5fc3dd84f8b40393e43f906 to your computer and use it in GitHub Desktop.
Save vladar/3fbc37d2f5fc3dd84f8b40393e43f906 to your computer and use it in GitHub Desktop.
Dynamic nested connections in GraphQL
const query = graphql`
{
allFoo(filter: { foo: { eq: "foo" }}) {
nodes {
id
foo
fooBars @connect(field: "allBar", filter: { fooId: { eq: this__id } }) {
nodes {
bar
}
}
}
}
}
`
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