Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(static-query): Use @babel/traverse for traversing algorithm #10443

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-remove-graphql-queries": "^2.5.2",
"babel-preset-gatsby": "^0.1.6",
"babel-traverse": "6.26.0",
"better-queue": "^3.8.6",
"bluebird": "^3.5.0",
"browserslist": "3.2.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/bootstrap/resolve-module-exports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
const fs = require(`fs`)
const traverse = require(`babel-traverse`).default
const traverse = require(`@babel/traverse`).default
const get = require(`lodash/get`)
const { codeFrameColumns } = require(`@babel/code-frame`)
const { babelParseToAst } = require(`../utils/babel-parse-to-ast`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,118 @@ Map {
],
"kind": "Document",
},
"fragment-shorthand.js" => Object {
"definitions": Array [
Object {
"directives": Array [],
"hash": 1097489062,
"isStaticQuery": true,
"kind": "OperationDefinition",
"loc": Object {
"end": 74,
"start": 3,
},
"name": Object {
"kind": "Name",
"value": "fragmentShorthandJs1097489062",
},
"operation": "query",
"selectionSet": Object {
"kind": "SelectionSet",
"loc": Object {
"end": 74,
"start": 9,
},
"selections": Array [
Object {
"alias": undefined,
"arguments": Array [],
"directives": Array [],
"kind": "Field",
"loc": Object {
"end": 70,
"start": 15,
},
"name": Object {
"kind": "Name",
"loc": Object {
"end": 19,
"start": 15,
},
"value": "site",
},
"selectionSet": Object {
"kind": "SelectionSet",
"loc": Object {
"end": 70,
"start": 20,
},
"selections": Array [
Object {
"alias": undefined,
"arguments": Array [],
"directives": Array [],
"kind": "Field",
"loc": Object {
"end": 64,
"start": 28,
},
"name": Object {
"kind": "Name",
"loc": Object {
"end": 40,
"start": 28,
},
"value": "siteMetadata",
},
"selectionSet": Object {
"kind": "SelectionSet",
"loc": Object {
"end": 64,
"start": 41,
},
"selections": Array [
Object {
"alias": undefined,
"arguments": Array [],
"directives": Array [],
"kind": "Field",
"loc": Object {
"end": 56,
"start": 51,
},
"name": Object {
"kind": "Name",
"loc": Object {
"end": 56,
"start": 51,
},
"value": "title",
},
"selectionSet": undefined,
},
],
},
},
],
},
},
],
},
"text": "
query {
site {
siteMetadata {
title
}
}
}
",
"variableDefinitions": Array [],
},
],
"kind": "Document",
},
"query-in-separate-variable.js" => Object {
"definitions": Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ export const fragment3 = graphql\`
}
\`
`,
"fragment-shorthand.js": `import React from "react"
import { StaticQuery, graphql } from "gatsby"

const query = graphql\`
query {
site {
siteMetadata {
title
}
}
}
\`

export default () => (
<>
<StaticQuery
query={query}
render={data => <div>{data.title}</div>}
/>
</>
)`,
"query-in-separate-variable.js": `import React from "react"
import { StaticQuery, graphql } from "gatsby"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const crypto = require(`crypto`)
const _ = require(`lodash`)

// Traverse is a es6 module...
import traverse from "babel-traverse"
import traverse from "@babel/traverse"
const getGraphQLTag = require(`babel-plugin-remove-graphql-queries`)
.getGraphQLTag
const report = require(`gatsby-cli/lib/reporter`)
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3701,7 +3701,7 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0, babel-te
babylon "^6.18.0"
lodash "^4.17.4"

babel-traverse@6.26.0, babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0:
babel-traverse@^6.0.0, babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee"
integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=
Expand Down Expand Up @@ -9122,7 +9122,7 @@ graphql-type-json@^0.2.1:
resolved "https://registry.yarnpkg.com/graphql-type-json/-/graphql-type-json-0.2.1.tgz#d2c177e2f1b17d87f81072cd05311c0754baa420"
integrity sha1-0sF34vGxfYf4EHLNBTEcB1S6pCA=

graphql@0.13.2, graphql@^0.13.0, graphql@^0.13.2:
graphql@^0.13.0, graphql@^0.13.2:
version "0.13.2"
resolved "http://registry.npmjs.org/graphql/-/graphql-0.13.2.tgz#4c740ae3c222823e7004096f832e7b93b2108270"
integrity sha512-QZ5BL8ZO/B20VA8APauGBg3GyEgZ19eduvpLWoq5x7gMmWnHoy8rlQWPLmWgFvo1yNgjSEFMesmS4R6pPr7xog==
Expand Down