Skip to content

Commit

Permalink
fix(gatsby): fix extracting StaticQuery nested in shorthand fragment (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
victorandcode authored and pieh committed Dec 13, 2018
1 parent 45d2832 commit d504d44
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 4 deletions.
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
2 changes: 1 addition & 1 deletion 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

0 comments on commit d504d44

Please sign in to comment.