Skip to content

Commit

Permalink
fix(gatsby): Update internal usage of .runQuery (#33571)
Browse files Browse the repository at this point in the history
* initial

* update tests

* update

* try fix

* accept GatsbyIterable in materialization

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
  • Loading branch information
LekoArts and vladar authored Oct 18, 2021
1 parent 677760c commit a800d9d
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 150 deletions.
11 changes: 6 additions & 5 deletions packages/gatsby/src/query/__tests__/data-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,9 +1291,8 @@ describe(`query caching between builds`, () => {
createSchemaCustomization: ({ actions: { createTypes }, schema }) => {
// Define fields with custom resolvers first
const resolveOne = type => (value, args, context) =>
context.nodeModel.runQuery({
context.nodeModel.findOne({
query: { testId: { eq: value.id } },
firstOnly: true,
type,
})

Expand Down Expand Up @@ -1321,11 +1320,13 @@ describe(`query caching between builds`, () => {
},
fooList: {
type: [`Foo`],
resolve: (value, args, context) =>
context.nodeModel.runQuery({
resolve: async (value, args, context) => {
const { entries } = await context.nodeModel.findAll({
query: { testId: { eq: value.id } },
type: `Foo`,
}),
})
return entries
},
},
barList: {
type: [`Bar`],
Expand Down
7 changes: 4 additions & 3 deletions packages/gatsby/src/schema/__tests__/kitchen-sink.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ const mockCreateResolvers = ({ createResolvers }) => {
likedEnough: {
type: `[PostsJson]`,
async resolve(parent, args, context) {
const result = await context.nodeModel.runQuery({
const { entries } = await context.nodeModel.findAll({
type: `PostsJson`,
query: {
limit: 2,
skip: 0,
filter: {
likes: {
ne: null,
Expand All @@ -356,9 +358,8 @@ const mockCreateResolvers = ({ createResolvers }) => {
order: [`DESC`],
},
},
firstOnly: false,
})
return result.slice(0, 2)
return entries
},
},
},
Expand Down
Loading

0 comments on commit a800d9d

Please sign in to comment.