Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: gatsby@4.6.1
Choose a base ref
...
head repository: gatsbyjs/gatsby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: gatsby@4.6.2
Choose a head ref
  • 3 commits
  • 7 files changed
  • 4 contributors

Commits on Feb 4, 2022

  1. fix(gatsby): Local file lookups in eq: $id queries (#34699) (#34717)

    Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
    Co-authored-by: Lennart <lekoarts@gmail.com>
    3 people authored Feb 4, 2022
    Copy the full SHA
    7c2f404 View commit details
  2. fix(create-gatsby): Use MDX v1 (#34710) (#34718)

    Co-authored-by: Lennart <lekoarts@gmail.com>
    gatsbybot and LekoArts authored Feb 4, 2022
    Copy the full SHA
    8b7b0e1 View commit details
  3. chore(release): Publish

     - create-gatsby@2.6.1
     - gatsby-cli@4.6.1
     - gatsby@4.6.2
    marvinjude committed Feb 4, 2022
    Copy the full SHA
    339232e View commit details
2 changes: 1 addition & 1 deletion packages/create-gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-gatsby",
"version": "2.6.0",
"version": "2.6.1",
"main": "lib/index.js",
"bin": "cli.js",
"license": "MIT",
2 changes: 1 addition & 1 deletion packages/create-gatsby/src/features.json
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
"gatsby-plugin-mdx": {
"message": "Add Markdown and MDX support",
"plugins": ["gatsby-source-filesystem:pages"],
"dependencies": ["@mdx-js/react", "@mdx-js/mdx"],
"dependencies": ["@mdx-js/react@v1", "@mdx-js/mdx@v1"],
"options": {
"gatsby-source-filesystem:pages": {
"name": "pages",
4 changes: 2 additions & 2 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-cli",
"description": "Gatsby command-line interface for creating new sites and running Gatsby commands",
"version": "4.6.0",
"version": "4.6.1",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "cli.js"
@@ -25,7 +25,7 @@
"common-tags": "^1.8.2",
"configstore": "^5.0.1",
"convert-hrtime": "^3.0.0",
"create-gatsby": "^2.6.0",
"create-gatsby": "^2.6.1",
"envinfo": "^7.8.1",
"execa": "^5.1.1",
"fs-exists-cached": "^1.0.0",
4 changes: 2 additions & 2 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby",
"description": "Blazing fast modern site generator for React",
"version": "4.6.1",
"version": "4.6.2",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"bin": {
"gatsby": "./cli.js"
@@ -77,7 +77,7 @@
"find-cache-dir": "^3.3.2",
"fs-exists-cached": "1.0.0",
"fs-extra": "^10.0.0",
"gatsby-cli": "^4.6.0",
"gatsby-cli": "^4.6.1",
"gatsby-core-utils": "^3.6.0",
"gatsby-graphiql-explorer": "^2.6.0",
"gatsby-legacy-polyfills": "^2.6.0",
12 changes: 12 additions & 0 deletions packages/gatsby/src/schema/__tests__/fixtures/queries.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const os = require(`os`)
const path = require(`path`)

const dir = os.platform() === "win32" ? "C:/Users/test/site" : "/home/test/site"

const nodes = [
{
id: `file1`,
@@ -8,6 +13,8 @@ const nodes = [
contentDigest: `file1`,
},
name: `1.md`,
dir,
absolutePath: path.posix.join(dir, `1.md`)
},
{
id: `file2`,
@@ -18,6 +25,8 @@ const nodes = [
contentDigest: `file2`,
},
name: `2.md`,
dir,
absolutePath: path.posix.join(dir, `2.md`)
},
{
id: `file3`,
@@ -28,6 +37,8 @@ const nodes = [
contentDigest: `file3`,
},
name: `authors.yaml`,
dir,
absolutePath: path.posix.join(dir, `authors.yaml`)
},
{
id: `md1`,
@@ -46,6 +57,7 @@ const nodes = [
authors: [`author2@example.com`, `author1@example.com`],
reviewer___NODE: `author2`,
reviewerByEmail: `author2@example.com`,
fileRef: `2.md`
},
},
{
34 changes: 33 additions & 1 deletion packages/gatsby/src/schema/__tests__/queries.js
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ describe(`Query schema`, () => {

const typeDefs = [
`type Markdown implements Node { frontmatter: Frontmatter! }`,
`type Frontmatter { authors: [Author] }`,
`type Frontmatter { authors: [Author], fileRef: File @fileByRelativePath }`,
`type Author implements Node { posts: [Markdown] }`,
]
typeDefs.forEach(def =>
@@ -2108,6 +2108,38 @@ describe(`Query schema`, () => {
}
})

it(`@fileByRelativePath works`, async () => {
const query = `
{
markdown(id: { eq: "md1"}) {
frontmatter {
title
fileRef {
childMarkdown {
frontmatter {
title
}
}
}
}
}
}
`
const results = await runQuery(query)

expect(results?.errors).toBeUndefined()
expect(results?.data?.markdown?.frontmatter?.title).toEqual(
`Markdown File 1`
)

// main assertion - markdown.frontmatter.fileRef is a file referenced by local path
// we want to make sure it finds node correctly (and doesn't crash)
expect(
results?.data?.markdown?.frontmatter?.fileRef?.childMarkdown
?.frontmatter?.title
).toEqual(`Markdown File 2`)
})

describe(`doesn't try to use fast path if there are more or different filters than just id.eq`, () => {
it(`using single filter different than id.eq`, async () => {
const results = await runQuery(
13 changes: 4 additions & 9 deletions packages/gatsby/src/schema/node-model.js
Original file line number Diff line number Diff line change
@@ -282,15 +282,10 @@ class LocalNodeModel {
})
runQueryActivity.start()
}
let nodeFoundById = getDataStore().getNode(query.filter.id.eq)

// make sure our node is of compatible type
if (
nodeFoundById &&
!nodeTypeNames.includes(nodeFoundById.internal.type)
) {
nodeFoundById = null
}
const nodeFoundById = this.getNodeById({
id: query.filter.id.eq,
type: gqlType,
})

if (runQueryActivity) {
runQueryActivity.end()