Skip to content

Commit

Permalink
feat(gatsby): Remove possibility to use global graphql tag for queries (
Browse files Browse the repository at this point in the history
#29291)

Co-authored-by: gatsbybot <[email protected]>
  • Loading branch information
LekoArts and gatsbybot authored Feb 10, 2021
1 parent a1f3cf6 commit d933462
Show file tree
Hide file tree
Showing 5 changed files with 989 additions and 923 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Allow alternative import of useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Allow alternative import of useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
import * as Gatsby from 'gatsby';
Expand All @@ -11,7 +11,7 @@ export default (() => {
});"
`;

exports[`Allow alternative import of useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Allow alternative import of useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -36,7 +36,7 @@ var _default = () => {
exports.default = _default;"
`;

exports[`Doesn't add data import for non static queries 1`] = `
exports[`babel-plugin-remove-graphql-queries Doesn't add data import for non static queries 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
import { StaticQuery } from \\"gatsby\\";
Expand All @@ -51,7 +51,7 @@ export default Test;
const fragment = \\"4176178832\\";"
`;

exports[`Doesn't add data import for non static queries 2`] = `
exports[`babel-plugin-remove-graphql-queries Doesn't add data import for non static queries 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -78,7 +78,7 @@ exports.default = _default;
const fragment = \\"4176178832\\";"
`;

exports[`Handles closing StaticQuery tag 1`] = `
exports[`babel-plugin-remove-graphql-queries Handles closing StaticQuery tag 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
import { StaticQuery } from 'gatsby';
Expand All @@ -88,7 +88,7 @@ export default (() => /*#__PURE__*/React.createElement(StaticQuery, {
}, data => /*#__PURE__*/React.createElement(\\"div\\", null, data.site.siteMetadata.title)));"
`;

exports[`Handles closing StaticQuery tag 2`] = `
exports[`babel-plugin-remove-graphql-queries Handles closing StaticQuery tag 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -112,7 +112,7 @@ var _default = () => /*#__PURE__*/React.createElement(_gatsby.StaticQuery, {
exports.default = _default;"
`;

exports[`Leaves other graphql tags alone 1`] = `
exports[`babel-plugin-remove-graphql-queries Leaves other graphql tags alone 1`] = `
"import * as React from 'react';
import { graphql } from 'relay';
export default (() => /*#__PURE__*/React.createElement(\\"div\\", null, data.site.siteMetadata.title));
Expand All @@ -123,7 +123,7 @@ export const query = graphql\`
\`;"
`;

exports[`Leaves other graphql tags alone 2`] = `
exports[`babel-plugin-remove-graphql-queries Leaves other graphql tags alone 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -146,7 +146,7 @@ const query = (0, _relay.graphql)\`
exports.query = query;"
`;

exports[`Only runs transforms if useStaticQuery is imported from gatsby 1`] = `
exports[`babel-plugin-remove-graphql-queries Only runs transforms if useStaticQuery is imported from gatsby 1`] = `
"import * as React from 'react';
export default (() => {
const query = \\"426988268\\";
Expand All @@ -155,7 +155,7 @@ export default (() => {
});"
`;

exports[`Only runs transforms if useStaticQuery is imported from gatsby 2`] = `
exports[`babel-plugin-remove-graphql-queries Only runs transforms if useStaticQuery is imported from gatsby 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -174,13 +174,13 @@ var _default = () => {
exports.default = _default;"
`;

exports[`Removes all gatsby queries 1`] = `
exports[`babel-plugin-remove-graphql-queries Removes all gatsby queries 1`] = `
"export default (() => /*#__PURE__*/React.createElement(\\"div\\", null, data.site.siteMetadata.title));
const siteMetaQuery = \\"504726680\\";
const query = \\"3211238532\\";"
`;

exports[`Removes all gatsby queries 2`] = `
exports[`babel-plugin-remove-graphql-queries Removes all gatsby queries 2`] = `
"\\"use strict\\";
exports.__esModule = true;
Expand All @@ -193,7 +193,7 @@ const siteMetaQuery = \\"504726680\\";
const query = \\"3211238532\\";"
`;

exports[`Transformation does not break custom hooks 1`] = `
exports[`babel-plugin-remove-graphql-queries Transformation does not break custom hooks 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import React from \\"react\\";
Expand All @@ -208,7 +208,7 @@ export default (() => {
});"
`;

exports[`Transformation does not break custom hooks 2`] = `
exports[`babel-plugin-remove-graphql-queries Transformation does not break custom hooks 2`] = `
"\\"use strict\\";
var _interopRequireDefault = require(\\"@babel/runtime/helpers/interopRequireDefault\\");
Expand All @@ -233,7 +233,7 @@ var _default = () => {
exports.default = _default;"
`;

exports[`Transforms exported queries in useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms exported queries in useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
export default (() => {
Expand All @@ -243,7 +243,7 @@ export default (() => {
export const query = \\"426988268\\";"
`;

exports[`Transforms exported queries in useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms exported queries in useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -267,7 +267,7 @@ const query = \\"426988268\\";
exports.query = query;"
`;

exports[`Transforms only the call expression in useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms only the call expression in useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import React from \\"react\\";
Expand All @@ -281,7 +281,7 @@ export default (() => {
});"
`;

exports[`Transforms only the call expression in useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms only the call expression in useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireDefault = require(\\"@babel/runtime/helpers/interopRequireDefault\\");
Expand All @@ -305,7 +305,7 @@ var _default = () => {
exports.default = _default;"
`;

exports[`Transforms queries and preserves destructuring in useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries and preserves destructuring in useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
export default (() => {
Expand All @@ -317,7 +317,7 @@ export default (() => {
});"
`;

exports[`Transforms queries and preserves destructuring in useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries and preserves destructuring in useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -342,7 +342,7 @@ var _default = () => {
exports.default = _default;"
`;

exports[`Transforms queries and preserves variable type in useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries and preserves variable type in useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
export default (() => {
Expand All @@ -354,7 +354,7 @@ export default (() => {
});"
`;

exports[`Transforms queries and preserves variable type in useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries and preserves variable type in useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -379,7 +379,7 @@ var _default = () => {
exports.default = _default;"
`;

exports[`Transforms queries defined in own variable in <StaticQuery> 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries defined in own variable in <StaticQuery> 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
import { StaticQuery } from 'gatsby';
Expand All @@ -391,7 +391,7 @@ export default (() => /*#__PURE__*/React.createElement(StaticQuery, {
}));"
`;
exports[`Transforms queries defined in own variable in <StaticQuery> 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries defined in own variable in <StaticQuery> 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -418,7 +418,7 @@ var _default = () => /*#__PURE__*/React.createElement(_gatsby.StaticQuery, {
exports.default = _default;"
`;
exports[`Transforms queries defined in own variable in useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries defined in own variable in useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
export default (() => {
Expand All @@ -428,7 +428,7 @@ export default (() => {
});"
`;
exports[`Transforms queries defined in own variable in useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries defined in own variable in useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -451,7 +451,7 @@ var _default = () => {
exports.default = _default;"
`;
exports[`Transforms queries in <StaticQuery> 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries in <StaticQuery> 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
import { StaticQuery } from 'gatsby';
Expand All @@ -462,7 +462,7 @@ export default (() => /*#__PURE__*/React.createElement(StaticQuery, {
}));"
`;
exports[`Transforms queries in <StaticQuery> 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries in <StaticQuery> 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -487,15 +487,15 @@ var _default = () => /*#__PURE__*/React.createElement(_gatsby.StaticQuery, {
exports.default = _default;"
`;
exports[`Transforms queries in page components 1`] = `"const query = \\"426988268\\";"`;
exports[`babel-plugin-remove-graphql-queries Transforms queries in page components 1`] = `"const query = \\"426988268\\";"`;
exports[`Transforms queries in page components 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries in page components 2`] = `
"\\"use strict\\";
const query = \\"426988268\\";"
`;
exports[`Transforms queries in useStaticQuery 1`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries in useStaticQuery 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
export default (() => {
Expand All @@ -504,7 +504,7 @@ export default (() => {
});"
`;
exports[`Transforms queries in useStaticQuery 2`] = `
exports[`babel-plugin-remove-graphql-queries Transforms queries in useStaticQuery 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand All @@ -526,15 +526,15 @@ var _default = () => {
exports.default = _default;"
`;
exports[`allows the global tag 1`] = `"const query = \\"426988268\\";"`;
exports[`babel-plugin-remove-graphql-queries allows the global tag 1`] = `"const query = \\"426988268\\";"`;
exports[`allows the global tag 2`] = `
exports[`babel-plugin-remove-graphql-queries allows the global tag 2`] = `
"\\"use strict\\";
const query = \\"426988268\\";"
`;
exports[`distinguishes between the right tags 1`] = `
exports[`babel-plugin-remove-graphql-queries distinguishes between the right tags 1`] = `
"const foo = styled('div')\`
{
\${foo}
Expand All @@ -561,7 +561,7 @@ const pulse = keyframes\`
const query = \\"426988268\\";"
`;
exports[`distinguishes between the right tags 2`] = `
exports[`babel-plugin-remove-graphql-queries distinguishes between the right tags 2`] = `
"\\"use strict\\";
const foo = styled('div')\`
Expand Down Expand Up @@ -590,39 +590,39 @@ const pulse = keyframes\`
const query = \\"426988268\\";"
`;
exports[`handles import aliasing 1`] = `"const query = \\"426988268\\";"`;
exports[`babel-plugin-remove-graphql-queries handles import aliasing 1`] = `"const query = \\"426988268\\";"`;
exports[`handles import aliasing 2`] = `
exports[`babel-plugin-remove-graphql-queries handles import aliasing 2`] = `
"\\"use strict\\";
const query = \\"426988268\\";"
`;
exports[`handles require 1`] = `"const query = \\"426988268\\";"`;
exports[`babel-plugin-remove-graphql-queries handles require 1`] = `"const query = \\"426988268\\";"`;
exports[`handles require 2`] = `
exports[`babel-plugin-remove-graphql-queries handles require 2`] = `
"\\"use strict\\";
const query = \\"426988268\\";"
`;
exports[`handles require alias 1`] = `"const query = \\"426988268\\";"`;
exports[`babel-plugin-remove-graphql-queries handles require alias 1`] = `"const query = \\"426988268\\";"`;
exports[`handles require alias 2`] = `
exports[`babel-plugin-remove-graphql-queries handles require alias 2`] = `
"\\"use strict\\";
const query = \\"426988268\\";"
`;
exports[`handles require namespace 1`] = `"const query = \\"426988268\\";"`;
exports[`babel-plugin-remove-graphql-queries handles require namespace 1`] = `"const query = \\"426988268\\";"`;
exports[`handles require namespace 2`] = `
exports[`babel-plugin-remove-graphql-queries handles require namespace 2`] = `
"\\"use strict\\";
const query = \\"426988268\\";"
`;
exports[`transforms exported variable queries in <StaticQuery> 1`] = `
exports[`babel-plugin-remove-graphql-queries transforms exported variable queries in <StaticQuery> 1`] = `
"import staticQueryData from \\"public/static/d/426988268.json\\";
import * as React from 'react';
import { StaticQuery } from 'gatsby';
Expand All @@ -634,7 +634,7 @@ export default (() => /*#__PURE__*/React.createElement(StaticQuery, {
}));"
`;
exports[`transforms exported variable queries in <StaticQuery> 2`] = `
exports[`babel-plugin-remove-graphql-queries transforms exported variable queries in <StaticQuery> 2`] = `
"\\"use strict\\";
var _interopRequireWildcard = require(\\"@babel/runtime/helpers/interopRequireWildcard\\");
Expand Down
Loading

0 comments on commit d933462

Please sign in to comment.