Skip to content

Commit a800d9d

Browse files
LekoArtsvladar
andauthored
fix(gatsby): Update internal usage of .runQuery (#33571)
* initial * update tests * update * try fix * accept GatsbyIterable in materialization Co-authored-by: Vladimir Razuvaev <[email protected]>
1 parent 677760c commit a800d9d

File tree

6 files changed

+126
-150
lines changed

6 files changed

+126
-150
lines changed

packages/gatsby/src/query/__tests__/data-tracking.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,9 +1291,8 @@ describe(`query caching between builds`, () => {
12911291
createSchemaCustomization: ({ actions: { createTypes }, schema }) => {
12921292
// Define fields with custom resolvers first
12931293
const resolveOne = type => (value, args, context) =>
1294-
context.nodeModel.runQuery({
1294+
context.nodeModel.findOne({
12951295
query: { testId: { eq: value.id } },
1296-
firstOnly: true,
12971296
type,
12981297
})
12991298

@@ -1321,11 +1320,13 @@ describe(`query caching between builds`, () => {
13211320
},
13221321
fooList: {
13231322
type: [`Foo`],
1324-
resolve: (value, args, context) =>
1325-
context.nodeModel.runQuery({
1323+
resolve: async (value, args, context) => {
1324+
const { entries } = await context.nodeModel.findAll({
13261325
query: { testId: { eq: value.id } },
13271326
type: `Foo`,
1328-
}),
1327+
})
1328+
return entries
1329+
},
13291330
},
13301331
barList: {
13311332
type: [`Bar`],

packages/gatsby/src/schema/__tests__/kitchen-sink.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,11 @@ const mockCreateResolvers = ({ createResolvers }) => {
342342
likedEnough: {
343343
type: `[PostsJson]`,
344344
async resolve(parent, args, context) {
345-
const result = await context.nodeModel.runQuery({
345+
const { entries } = await context.nodeModel.findAll({
346346
type: `PostsJson`,
347347
query: {
348+
limit: 2,
349+
skip: 0,
348350
filter: {
349351
likes: {
350352
ne: null,
@@ -356,9 +358,8 @@ const mockCreateResolvers = ({ createResolvers }) => {
356358
order: [`DESC`],
357359
},
358360
},
359-
firstOnly: false,
360361
})
361-
return result.slice(0, 2)
362+
return entries
362363
},
363364
},
364365
},

0 commit comments

Comments
 (0)