Repository: gatsbyjs/gatsby
File: packages/gatsby/src/schema/__tests__/queries.js (JavaScript)

Code before:
                    .getAllNodes({ type: `Author` })
                    .filter(author => source.authors.includes(author.email))
                },
              },
            },
            Author: {
              posts: {
                resolve(source, args, context, info) {
                  // NOTE: One of the differences between using `runQuery` and
                  // `getAllNodes` is that the latter will always get the nodes
                  // which will be queried directly from the store, while `runQuery`
                  // will first try to call field resolvers, e.g. to expand
                  // foreign-key fields to full nodes. Here for example we can
                  // query `authors.email`.
                  // Another thing to note is that we don't have to use the
                  // `$elemMatch` operator when querying arrays of objects
                  // (although we could).
                  return context.nodeModel.runQuery({
                    type: `Markdown`,
                    query: {
                      filter: {
                        frontmatter: {
                          authors: { email: { eq: source.email } },
                          // authors: {
                          //   elemMatch: { email: { eq: source.email } },
                          // },
                        },
                      },
                    },
                    firstOnly: false,
                  })
                },
              },
            },
          }),
          args[0].createResolvers({
            Query: {
              allAuthorNames: {
                type: `[String!]!`,
                resolve(source, args, context, info) {
                  return context.nodeModel
                    .getAllNodes({ type: `Author` })
                    .map(author => author.name)
                },
              },
            },
          }),
        ]
      } else {
        return []
      }

Review comment (bug):
Note: I've verified with @freiksenet that this test was broken and should not have relied on `eq` working on arrays. Heck, the equivalent `elemMatch` code was still here anyways, so reverting to that.

Code after:
                    .getAllNodes({ type: `Author` })
                    .filter(author => source.authors.includes(author.email))
                },
              },
            },
            Author: {
              posts: {
                resolve(source, args, context, info) {
                  // NOTE: One of the differences between using `runQuery` and
                  // `getAllNodes` is that the latter will always get the nodes
                  // which will be queried directly from the store, while `runQuery`
                  // will first try to call field resolvers, e.g. to expand
                  // foreign-key fields to full nodes. Here for example we can
                  // query `authors.email`.
                  // Another thing to note is that we don't have to use the
                  // `$elemMatch` operator when querying arrays of objects
                  // (although we could).
                  return context.nodeModel.runQuery({
                    type: `Markdown`,
                    query: {
                      filter: {
                        frontmatter: {
                          // authors: { email: { eq: source.email } },
                          authors: {
                            elemMatch: { email: { eq: source.email } },
                          },
                        },
                      },
                    },
                    firstOnly: false,
                  })
                },
              },
            },
          }),
          args[0].createResolvers({
            Query: {
              allAuthorNames: {
                type: `[String!]!`,
                resolve(source, args, context, info) {
                  return context.nodeModel
                    .getAllNodes({ type: `Author` })
                    .map(author => author.name)
                },
              },
            },
          }),
        ]
      } else {
        return []
      }