gatsby
gatsby copied to clipboard
docs: Example @link directive with array (by elemMatch)
Preliminary Checks
- [X] This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- [X] This issue is not a question, feature request, RFC, or anything other than a bug report. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Summary
Previous issues:
- #25089
- #25077
After looking into a custom createFieldExtension
, I discovered that elemMatch
works and subsequently found this:
https://github.com/gatsbyjs/gatsby/issues/25336#issuecomment-652276026
Steps to Resolve this Issue
The docs should clarify that this works:
type Author implements Node {
id: ID!
name: String!
email: String!
- posts: [Post!]! @link(from: "email", by: "authors.email")
+ posts: [Post!]! @link(from: "email", by: "authors.elemMatch.email")
}
type Post implements Node {
id: ID!
title: String!
body: String!
authors: [Author!]! @link(by: "email")
tags: [Tag!]! @link
}
type Tag implements Node {
id: ID!
label: String!
description: String!
- posts: [Post!]! @link(from: "id", by: "tags.id")
+ posts: [Post!]! @link(from: "id", by: "tags.elemMatch.id")
}
This works because how the query is formed by splitting on .
:
https://github.com/gatsbyjs/gatsby/blob/564a8f7358edd2599199e79c902468fa83f916b2/packages/gatsby/src/schema/resolvers.ts#L416-L423
Happy to review a PR changing this!
https://www.gatsbyjs.com/contributing/how-to-open-a-pull-request/
Can I work on this issue @LekoArts ?
Absolutely @aryans1319! Feel free to jump on this.
Can you assign this to me?
Sure thing 👍
Hi @cpboyd @LekoArts , I'm interested in above task, can you pls let me know whether the above task is still open.