[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\nindent_size = 2\nindent_style = space\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"extends\": [\n    \"canonical\"\n  ],\n  \"root\": true\n}\n"
  },
  {
    "path": ".flowconfig",
    "content": "[ignore]\n<PROJECT_ROOT>/node_modules/config-chain/test/broken.json\n<PROJECT_ROOT>/node_modules/conventional-changelog-core/test/fixtures/_malformation.json\n<PROJECT_ROOT>/node_modules/npmconf/test/fixtures/package.json\n"
  },
  {
    "path": ".gitignore",
    "content": "coverage\ndist\nnode_modules\n*.log\n.*\n!.babelrc\n!.editorconfig\n!.eslintrc\n!.flowconfig\n!.gitignore\n!.npmignore\n!.README\n!.travis.yml\n"
  },
  {
    "path": ".npmignore",
    "content": "src\ntest\ncoverage\n.*\n*.log\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n  - 14\nscript:\n  - npm run lint\n  - npm run build\n  - npm run test\nafter_success:\n  - NODE_ENV=production npm run build\n  - semantic-release\nnotifications:\n  email: false\nsudo: false\n"
  },
  {
    "path": "LICENSE",
    "content": "Copyright (c) 2016, Gajus Kuizinas (http://gajus.com/)\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of the Gajus Kuizinas (http://gajus.com/) nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL ANUARY BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "README.md",
    "content": "# babel-plugin-graphql-tag\n\n[![GitSpo Mentions](https://gitspo.com/badges/mentions/gajus/babel-plugin-graphql-tag?style=flat-square)](https://gitspo.com/mentions/gajus/babel-plugin-graphql-tag)\n[![Travis build status](http://img.shields.io/travis/gajus/babel-plugin-graphql-tag/master.svg?style=flat-square)](https://travis-ci.org/gajus/babel-plugin-graphql-tag)\n[![NPM version](http://img.shields.io/npm/v/babel-plugin-graphql-tag.svg?style=flat-square)](https://www.npmjs.org/package/babel-plugin-graphql-tag)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)\n\nCompiles GraphQL tagged template strings using [graphql-tag](https://github.com/apollographql/graphql-tag).\n\n## Motivation\n\nCompiling GraphQL queries at the build time:\n\n* reduces the script initialization time; and\n* removes the `graphql-tag` dependency\n\nRemoving the `graphql-tag` dependency from the bundle saves approx. 50 KB.\n\n## Implementation\n\n* Searches for imports of `graphql-tag` and removes them.\n* Searches for [tagged template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals) with `gql` identifier and compiles them using `graphql-tag`.\n\n## Example compilation\n\nInput:\n\n```js\nimport gql from 'graphql-tag';\n// if using apollo v3\nimport { gql } from '@apollo/client';\n\nconst foo = gql`query {bar}`;\n\n```\n\nOutput:\n\n```js\nconst foo = {\n  \"definitions\": [\n    {\n      \"directives\": [\n      ],\n      \"kind\": \"OperationDefinition\",\n      \"operation\": \"query\",\n      \"selectionSet\": {\n        \"kind\": \"SelectionSet\",\n        \"selections\": [\n          {\n            \"alias\": null,\n            \"arguments\": [\n            ],\n            \"directives\": [\n            ],\n            \"kind\": \"Field\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"bar\"\n            },\n            \"selectionSet\": null\n          }\n        ]\n      },\n      \"variableDefinitions\": [\n      ]\n    }\n  ],\n  \"kind\": \"Document\",\n  \"loc\": {\n    \"end\": 11,\n    \"start\": 0\n  }\n};\n\n```\n\n**NOTE: require() is also supported.**\n\n### Using fragments\n\nUsing GraphQL [fragments](http://graphql.org/learn/queries/#fragments) requires to:\n\n1. Define a fragment using `graphql-tag`.\n2. Append the referenced fragment as a variable to the end of the GraphQL query.\n\nExample:\n\n```js\nimport gql from 'graphql-tag';\n\nconst bar = gql`\n  fragment barFragment on Foo {\n    field1\n    field2\n  }\n`;\n\nconst foo = gql`\n  query foo {\n    foo {\n      ...barFragment\n    }\n  }\n\n  ${bar}\n`;\n\n```\n\n### Options\n\n- `importSources` - An array of names for modules to import (default = `[\"graphql-tag\", \"@apollo/client\"]`)\n- `onlyMatchImportSuffix` - Matches the end of the import instead of the entire name. Useful for relative imports, e.g. `./utils/graphql` (default = false)\n- `strip` - Strips insignificant characters such as whitespace from the original GraphQL string literal to reduce the size of compiled AST (default = false)\n- `transform` - By default, graphql query strings will be replaced with their AST representations, but you can override that behavior and do whatever you like. One possible use case would be to implement persisted queries:\n- `gqlTagIdentifiers` - An array of names for gql tag identifiers (default = `[\"gql\"]`)\n\n```js\n// babel.config.js\nplugins: [\n    [\n        \"babel-plugin-graphql-tag\",\n        {\n            strip: true,\n            transform: (source, ast) => {\n                const h = hash(source); // use your favorite hashing method\n                graphqlAstHashes[h] = ast; // write this to a file when compilation is complete\n                return {\n                    queryId: h\n                };\n            }\n        }\n    ]\n]\n```\n\n### Known Issues\n\nSome cases are really hard to track down:\n\n```\nconst apolloClient = require('@apollo/client');\n// or\nimport apolloClient from '@apollo/client';\n\nconst { gql } = apolloClient;\n\nconst foo = gql`...`;\n```\n\nIf you have this kind of syntax, this plugin won't work for you.\n"
  },
  {
    "path": "babel.config.js",
    "content": "module.exports = {\n  presets: [\n    [\n      '@babel/preset-env',\n      {\n        modules: 'commonjs',\n        targets: {\n          node: 8\n        }\n      }\n    ],\n    '@babel/preset-flow'\n  ]\n};\n"
  },
  {
    "path": "jest.config.js",
    "content": "module.exports = {\n  testEnvironment: 'node'\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"dependencies\": {\n    \"@babel/helper-plugin-utils\": \"^7.0.0\",\n    \"@babel/parser\": \"^7.3.2\",\n    \"babel-literal-to-ast\": \"^2.1.0\",\n    \"debug\": \"^4.1.1\"\n  },\n  \"description\": \"Compiles GraphQL tagged template strings using graphql-tag\",\n  \"devDependencies\": {\n    \"@apollo/client\": \"^3.1.0\",\n    \"@babel/cli\": \"^7.2.3\",\n    \"@babel/core\": \"^7.2.2\",\n    \"@babel/helper-transform-fixture-test-runner\": \"^7.1.2\",\n    \"@babel/preset-env\": \"^7.3.1\",\n    \"@babel/preset-flow\": \"^7.0.0\",\n    \"cross-env\": \"^7.0.2\",\n    \"eslint\": \"^7.0.0\",\n    \"eslint-config-canonical\": \"^21.0.2\",\n    \"flow-bin\": \"^0.93.0\",\n    \"graphql\": \"^14.3.0\",\n    \"graphql-tag\": \"^2.10.1\",\n    \"husky\": \"^1.3.1\",\n    \"jest\": \"^24.1.0\",\n    \"semantic-release\": \"^17.1.2\"\n  },\n  \"husky\": {\n    \"hooks\": {\n      \"pre-commit\": \"npm run lint && npm run test\"\n    }\n  },\n  \"main\": \"dist/index.js\",\n  \"name\": \"babel-plugin-graphql-tag\",\n  \"peerDependencies\": {\n    \"@babel/core\": \"^7.0.0\",\n    \"graphql-tag\": \"^2.10.1\",\n    \"graphql\": \"^14.0.0 || ^15.0.0\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/gajus/babel-plugin-graphql-tag.git\"\n  },\n  \"resolutions\": {\n    \"jest\": \"^24.1.0\"\n  },\n  \"scripts\": {\n    \"build\": \"rm -fr ./dist && cross-env NODE_ENV=production babel ./src --out-dir ./dist --source-maps --copy-files\",\n    \"lint\": \"eslint ./src && flow\",\n    \"test\": \"cross-env NODE_ENV=test jest\"\n  },\n  \"version\": \"3.1.0\"\n}\n"
  },
  {
    "path": "src/index.js",
    "content": "/* eslint-disable prefer-exponentiation-operator */\n// @flow\n\nimport {types} from '@babel/core';\nimport {declare} from '@babel/helper-plugin-utils';\nimport {parseExpression} from '@babel/parser';\nimport parseLiteral from 'babel-literal-to-ast';\nimport gql from 'graphql-tag';\nimport createDebug from 'debug';\nimport {stripIgnoredCharacters} from 'graphql';\n\nconst debug = createDebug('babel-plugin-graphql-tag');\nconst {\n  addComment,\n  cloneDeep,\n  isIdentifier,\n  isMemberExpression,\n  isImportSpecifier,\n  isImportDefaultSpecifier,\n  variableDeclaration,\n  variableDeclarator,\n  memberExpression,\n  callExpression,\n  identifier,\n  isObjectPattern,\n} = types;\n\nconst PURE_ANNOTATION = '#__PURE__';\n\n// eslint-disable-next-line no-restricted-syntax\nconst uniqueFn = parseExpression(`\n  (definitions) => {\n    const names = {};\n    return definitions.filter(definition => {\n      if (definition.kind !== 'FragmentDefinition') {\n        return true;\n      }\n      const name = definition.name.value;\n      if (names[name]) {\n        return false;\n      } else {\n        names[name] = true;\n        return true;\n      }\n    });\n  }\n`);\n\nexport default declare((api, options) => {\n  api.assertVersion(7);\n  const {\n    importSources = ['graphql-tag', '@apollo/client'],\n    gqlTagIdentifiers = ['gql'],\n    onlyMatchImportSuffix = false,\n    strip = false,\n  } = options;\n\n  const gqlTagIdentifiersSet = new Set(gqlTagIdentifiers);\n\n  const compile = (path: Object, uniqueId) => {\n    // eslint-disable-next-line unicorn/no-reduce\n    const source = path.node.quasis.reduce((head, quasi) => {\n      return head + quasi.value.raw;\n    }, '');\n\n    const expressions = path.get('expressions');\n\n    expressions.forEach((expr) => {\n      if (!isIdentifier(expr) && !isMemberExpression(expr)) {\n        throw expr.buildCodeFrameError(\n          'Only identifiers or member expressions are allowed by this plugin as an interpolation in a graphql template literal.',\n        );\n      }\n    });\n\n    debug('compiling a GraphQL query', source);\n    const finalSource = strip ? stripIgnoredCharacters(source) : source;\n    let queryDocument = gql(strip ? stripIgnoredCharacters(finalSource) : finalSource);\n\n    // If a document contains only one operation, that operation may be unnamed:\n    // https://facebook.github.io/graphql/#sec-Language.Query-Document\n    if (queryDocument.definitions.length > 1) {\n      for (const definition of queryDocument.definitions) {\n        if (!definition.name) {\n          throw new Error('GraphQL query must have name.');\n        }\n      }\n    }\n\n    if (options.transform && options.transform) {\n      queryDocument = options.transform(finalSource, queryDocument);\n    }\n\n    const body = parseLiteral(queryDocument);\n    let uniqueUsed = false;\n\n    if (expressions.length) {\n      const definitionsProperty = body.properties.find((property) => {\n        return property.key.value === 'definitions';\n      });\n\n      const definitionsArray = definitionsProperty.value;\n\n      const extraDefinitions = expressions.map((expr) => {\n        return memberExpression(expr.node, identifier('definitions'));\n      });\n\n      const allDefinitions = callExpression(\n        memberExpression(definitionsArray, identifier('concat')),\n        extraDefinitions,\n      );\n\n      definitionsProperty.value = callExpression(uniqueId, [allDefinitions]);\n\n      // Marking these function calls with an annotation indicating that\n      // they're pure will allow bundlers like Webpack and Rollup to more\n      // aggressively remove unused queries from bundles.\n      addComment(allDefinitions, 'leading', PURE_ANNOTATION);\n      addComment(definitionsProperty.value, 'leading', PURE_ANNOTATION);\n\n      uniqueUsed = true;\n    }\n\n    debug('created a static representation', body);\n\n    return [body, uniqueUsed];\n  };\n\n  return {\n    visitor: {\n      Program (programPath: Object) {\n        const tagNames = [];\n        const pendingDeletion = [];\n        const uniqueId = programPath.scope.generateUidIdentifier('unique');\n        let uniqueUsed = false;\n        let hasError = false;\n\n        programPath.traverse({\n          CallExpression: {\n            enter (nodePath) {\n              const callee = nodePath.get('callee');\n              const {arguments: args} = nodePath.node;\n\n              if (callee.isIdentifier() && callee.equals('name', 'require')) {\n                const [{value: pathValue}] = args;\n                if (importSources.some((source) => {\n                  return onlyMatchImportSuffix ? pathValue.endsWith(source) : pathValue === source;\n                })) {\n                  if (nodePath.parentPath.isVariableDeclarator()) {\n                    const gqlDeclaration = nodePath.parentPath.parent.declarations[0];\n\n                    if (isObjectPattern(gqlDeclaration.id)) {\n                      const gqlProperty = gqlDeclaration.id.properties.find((property) => {\n                        return gqlTagIdentifiersSet.has(property.key.name);\n                      });\n                      tagNames.push(gqlProperty.key.name);\n\n                      if (gqlDeclaration.id.properties.length === 1) {\n                        pendingDeletion.push({\n                          defaultSpecifier: null,\n                          path: nodePath.parentPath,\n                        });\n                      }\n\n                      gqlDeclaration.id.properties = gqlDeclaration.id.properties.filter((property) => {\n                        return !gqlTagIdentifiersSet.has(property.key.name);\n                      });\n\n                      return;\n                    }\n\n                    tagNames.push(gqlDeclaration.id.name);\n                    pendingDeletion.push({\n                      defaultSpecifier: null,\n                      path: nodePath.parentPath,\n                    });\n                  }\n                }\n              }\n            },\n          },\n          ImportDeclaration (path: Object) {\n            const pathValue = path.node.source.value;\n            const gqlSpecifier = path.node.specifiers.find((specifier) => {\n              if (isImportSpecifier(specifier)) {\n                return gqlTagIdentifiersSet.has(specifier.local.name);\n              }\n\n              if (isImportDefaultSpecifier(specifier)) {\n                return importSources.some((source) => {\n                  return onlyMatchImportSuffix ? pathValue.endsWith(source) : pathValue === source;\n                });\n              }\n\n              return null;\n            });\n\n            if (gqlSpecifier) {\n              tagNames.push(gqlSpecifier.local.name);\n              pendingDeletion.push({\n                defaultSpecifier: gqlSpecifier,\n                path,\n              });\n            }\n          },\n          TaggedTemplateExpression (path: Object) {\n            if (\n              tagNames.some((name) => {\n                return isIdentifier(path.node.tag, {name});\n              })\n            ) {\n              try {\n                debug('quasi', path.node.quasi);\n                const [body, used] = compile(path.get('quasi'), uniqueId);\n\n                uniqueUsed = uniqueUsed || used;\n\n                path.replaceWith(cloneDeep(body));\n              } catch (error) {\n                // eslint-disable-next-line no-console\n                console.error('error', error);\n                hasError = true;\n              }\n            }\n          },\n        });\n\n        // Only delete import statement or specifier when there is no error\n        if (!hasError) {\n          for (const {defaultSpecifier, path: pathForDeletion} of pendingDeletion) {\n            if (defaultSpecifier === null) {\n              pathForDeletion.remove();\n              continue;\n            }\n            if (pathForDeletion.node.specifiers.length === 1) {\n              pathForDeletion.remove();\n            } else {\n              pathForDeletion.node.specifiers = pathForDeletion.node.specifiers.filter((specifier) => {\n                return specifier !== defaultSpecifier;\n              });\n            }\n          }\n        }\n\n        if (uniqueUsed) {\n          programPath.unshiftContainer(\n            'body',\n            variableDeclaration('const', [variableDeclarator(uniqueId, cloneDeep(uniqueFn))]),\n          );\n        }\n      },\n    },\n  };\n});\n"
  },
  {
    "path": "test/fixtures/apollov3/converts inline gql tag to a compiled version/input.js",
    "content": "import { gql } from '@apollo/client';\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/converts inline gql tag to a compiled version/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/converts inline gql tag to a compiled version/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/apollov3/converts inline gql tag with fragment interpolation/input.js",
    "content": "import { gql } from '@apollo/client';\n\nconst bar = gql`\n  fragment barFragment on Foo {\n    field1\n    field2\n  }\n`;\n\nconst baz = {\n  fragments: {\n    foo: gql`\n      fragment bazFragment on Foo {\n        field2\n        field3\n      }\n    `\n  }\n};\n\nconst foo = gql`\n  query foo {\n    foo {\n      ...barFragment\n      ...bazFragment\n    }\n  }\n\n  ${bar}\n  ${baz.fragments.foo}\n`;\n"
  },
  {
    "path": "test/fixtures/apollov3/converts inline gql tag with fragment interpolation/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/converts inline gql tag with fragment interpolation/output.mjs",
    "content": "const _unique = definitions => {\n  const names = {};\n  return definitions.filter(definition => {\n    if (definition.kind !== 'FragmentDefinition') {\n      return true;\n    }\n\n    const name = definition.name.value;\n\n    if (names[name]) {\n      return false;\n    } else {\n      names[name] = true;\n      return true;\n    }\n  });\n};\n\nconst bar = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"FragmentDefinition\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"barFragment\"\n    },\n    \"typeCondition\": {\n      \"kind\": \"NamedType\",\n      \"name\": {\n        \"kind\": \"Name\",\n        \"value\": \"Foo\"\n      }\n    },\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"field1\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }, {\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"field2\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 59,\n    \"source\": {\n      \"body\": \"\\n  fragment barFragment on Foo {\\n    field1\\n    field2\\n  }\\n\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\nconst baz = {\n  fragments: {\n    foo: {\n      \"kind\": \"Document\",\n      \"definitions\": [{\n        \"kind\": \"FragmentDefinition\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"bazFragment\"\n        },\n        \"typeCondition\": {\n          \"kind\": \"NamedType\",\n          \"name\": {\n            \"kind\": \"Name\",\n            \"value\": \"Foo\"\n          }\n        },\n        \"directives\": [],\n        \"selectionSet\": {\n          \"kind\": \"SelectionSet\",\n          \"selections\": [{\n            \"kind\": \"Field\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"field2\"\n            },\n            \"arguments\": [],\n            \"directives\": []\n          }, {\n            \"kind\": \"Field\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"field3\"\n            },\n            \"arguments\": [],\n            \"directives\": []\n          }]\n        }\n      }],\n      \"loc\": {\n        \"start\": 0,\n        \"end\": 79,\n        \"source\": {\n          \"body\": \"\\n      fragment bazFragment on Foo {\\n        field2\\n        field3\\n      }\\n    \",\n          \"name\": \"GraphQL request\",\n          \"locationOffset\": {\n            \"line\": 1,\n            \"column\": 1\n          }\n        }\n      }\n    }\n  }\n};\nconst foo = {\n  \"kind\": \"Document\",\n  \"definitions\": /*#__PURE__*/_unique( /*#__PURE__*/[{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": [],\n        \"selectionSet\": {\n          \"kind\": \"SelectionSet\",\n          \"selections\": [{\n            \"kind\": \"FragmentSpread\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"barFragment\"\n            },\n            \"directives\": []\n          }, {\n            \"kind\": \"FragmentSpread\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"bazFragment\"\n            },\n            \"directives\": []\n          }]\n        }\n      }]\n    }\n  }].concat(bar.definitions, baz.fragments.foo.definitions)),\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 84,\n    \"source\": {\n      \"body\": \"\\n  query foo {\\n    foo {\\n      ...barFragment\\n      ...bazFragment\\n    }\\n  }\\n\\n  \\n  \\n\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/apollov3/does not transpile template literals without a tag/input.js",
    "content": "import { gql } from '@apollo/client';\n\nconst foo = `query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/does not transpile template literals without a tag/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/does not transpile template literals without a tag/output.mjs",
    "content": "const foo = `query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/does not transpile template literals without gql tag/input.js",
    "content": "import { gql } from '@apollo/client';\n\nconst foo = bar`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/does not transpile template literals without gql tag/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/does not transpile template literals without gql tag/output.mjs",
    "content": "const foo = bar`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/handles different imports based on options/input.js",
    "content": "import { gql } from \"../../../node_modules/@apollo/client\";\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/handles different imports based on options/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\",\n      {\n        \"importName\": \"@apollo/client\",\n        \"onlyMatchImportSuffix\": true\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/handles different imports based on options/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};"
  },
  {
    "path": "test/fixtures/apollov3/preserves imports when cannot parse query/input.js",
    "content": "import { gql } from '@apollo/client';\nconst bar = gql`query foo {`;\n"
  },
  {
    "path": "test/fixtures/apollov3/preserves imports when cannot parse query/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/preserves imports when cannot parse query/output.mjs",
    "content": "import { gql } from '@apollo/client';\nconst bar = gql`query foo {`;\n"
  },
  {
    "path": "test/fixtures/apollov3/preserves other imports from graphql-tag package/input.js",
    "content": "import { gql, other } from '@apollo/client';\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/preserves other imports from graphql-tag package/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/preserves other imports from graphql-tag package/output.mjs",
    "content": "import { other } from '@apollo/client';\nconst foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/apollov3/strips ignored characters from source/input.js",
    "content": "import { gql } from '@apollo/client';\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/strips ignored characters from source/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\",\n      {\n        \"importName\": \"@apollo/client\",\n        \"strip\": true\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/strips ignored characters from source/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 14,\n    \"source\": {\n      \"body\": \"query foo{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query/input.js",
    "content": "import { gql } from '@apollo/client';\n\nconst foo = gql`{foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 5,\n    \"source\": {\n      \"body\": \"{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query with require/input.js",
    "content": "const { gql } = require('@apollo/client');\n\nconst foo = gql`{foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query with require/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query with require/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 5,\n    \"source\": {\n      \"body\": \"{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query with require and other tool/input.js",
    "content": "const { gql, useQuery } = require('@apollo/client');\n\nconst foo = gql`{foo}`;\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query with require and other tool/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/apollov3/transpiles a single unnamed query with require and other tool/output.mjs",
    "content": "const {\n  useQuery\n} = require('@apollo/client');\n\nconst foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 5,\n    \"source\": {\n      \"body\": \"{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/allows a custom tag identifier/input.js",
    "content": "import { gqlTagPrimaryGateway } from 'primary-gateway-graphql-tag';\n\nconst foo = gqlTagPrimaryGateway`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/allows a custom tag identifier/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\",\n      {\n        \"importSources\": [\"@apollo/client\", \"primary-gateway-graphql-tag\"],\n        \"gqlTagIdentifiers\": [\"gql\", \"gqlTagPrimaryGateway\"],\n        \"strip\": true\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/allows a custom tag identifier/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 14,\n    \"source\": {\n      \"body\": \"query foo{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/converts inline gql tag to a compiled version/input.js",
    "content": "import gql from 'graphql-tag';\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/converts inline gql tag to a compiled version/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/converts inline gql tag to a compiled version/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/converts inline gql tag with fragment interpolation/input.js",
    "content": "import gql from 'graphql-tag';\n\nconst bar = gql`\n  fragment barFragment on Foo {\n    field1\n    field2\n  }\n`;\n\nconst baz = {\n  fragments: {\n    foo: gql`\n      fragment bazFragment on Foo {\n        field2\n        field3\n      }\n    `\n  }\n};\n\nconst foo = gql`\n  query foo {\n    foo {\n      ...barFragment\n      ...bazFragment\n    }\n  }\n\n  ${bar}\n  ${baz.fragments.foo}\n`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/converts inline gql tag with fragment interpolation/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/converts inline gql tag with fragment interpolation/output.mjs",
    "content": "const _unique = definitions => {\n  const names = {};\n  return definitions.filter(definition => {\n    if (definition.kind !== 'FragmentDefinition') {\n      return true;\n    }\n\n    const name = definition.name.value;\n\n    if (names[name]) {\n      return false;\n    } else {\n      names[name] = true;\n      return true;\n    }\n  });\n};\n\nconst bar = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"FragmentDefinition\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"barFragment\"\n    },\n    \"typeCondition\": {\n      \"kind\": \"NamedType\",\n      \"name\": {\n        \"kind\": \"Name\",\n        \"value\": \"Foo\"\n      }\n    },\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"field1\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }, {\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"field2\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 59,\n    \"source\": {\n      \"body\": \"\\n  fragment barFragment on Foo {\\n    field1\\n    field2\\n  }\\n\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\nconst baz = {\n  fragments: {\n    foo: {\n      \"kind\": \"Document\",\n      \"definitions\": [{\n        \"kind\": \"FragmentDefinition\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"bazFragment\"\n        },\n        \"typeCondition\": {\n          \"kind\": \"NamedType\",\n          \"name\": {\n            \"kind\": \"Name\",\n            \"value\": \"Foo\"\n          }\n        },\n        \"directives\": [],\n        \"selectionSet\": {\n          \"kind\": \"SelectionSet\",\n          \"selections\": [{\n            \"kind\": \"Field\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"field2\"\n            },\n            \"arguments\": [],\n            \"directives\": []\n          }, {\n            \"kind\": \"Field\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"field3\"\n            },\n            \"arguments\": [],\n            \"directives\": []\n          }]\n        }\n      }],\n      \"loc\": {\n        \"start\": 0,\n        \"end\": 79,\n        \"source\": {\n          \"body\": \"\\n      fragment bazFragment on Foo {\\n        field2\\n        field3\\n      }\\n    \",\n          \"name\": \"GraphQL request\",\n          \"locationOffset\": {\n            \"line\": 1,\n            \"column\": 1\n          }\n        }\n      }\n    }\n  }\n};\nconst foo = {\n  \"kind\": \"Document\",\n  \"definitions\": /*#__PURE__*/_unique( /*#__PURE__*/[{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": [],\n        \"selectionSet\": {\n          \"kind\": \"SelectionSet\",\n          \"selections\": [{\n            \"kind\": \"FragmentSpread\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"barFragment\"\n            },\n            \"directives\": []\n          }, {\n            \"kind\": \"FragmentSpread\",\n            \"name\": {\n              \"kind\": \"Name\",\n              \"value\": \"bazFragment\"\n            },\n            \"directives\": []\n          }]\n        }\n      }]\n    }\n  }].concat(bar.definitions, baz.fragments.foo.definitions)),\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 84,\n    \"source\": {\n      \"body\": \"\\n  query foo {\\n    foo {\\n      ...barFragment\\n      ...bazFragment\\n    }\\n  }\\n\\n  \\n  \\n\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/does not transpile template literals without a tag/input.js",
    "content": "import gql from 'graphql-tag';\n\nconst foo = `query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/does not transpile template literals without a tag/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/does not transpile template literals without a tag/output.mjs",
    "content": "const foo = `query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/does not transpile template literals without gql tag/input.js",
    "content": "import gql from 'graphql-tag';\n\nconst foo = bar`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/does not transpile template literals without gql tag/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/does not transpile template literals without gql tag/output.mjs",
    "content": "const foo = bar`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/handles different imports based on options/input.js",
    "content": "import gql from \"../../../node_modules/graphql-tag\";\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/handles different imports based on options/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\",\n      {\n        \"onlyMatchImportSuffix\": true\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/handles different imports based on options/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};"
  },
  {
    "path": "test/fixtures/graphql-tag/handles gql tag with alternative names/input.js",
    "content": "import first from 'graphql-tag';\nimport second from 'graphql-tag';\n\nconst foo = first`query foo {foo}`;\nconst bar = second`query bar {bar}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/handles gql tag with alternative names/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/handles gql tag with alternative names/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\nconst bar = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"bar\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"bar\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query bar {bar}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/preserves imports when cannot parse query/input.js",
    "content": "import gql from 'graphql-tag';\nconst bar = gql`query foo {`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/preserves imports when cannot parse query/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/preserves imports when cannot parse query/output.mjs",
    "content": "import gql from 'graphql-tag';\nconst bar = gql`query foo {`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/preserves other imports from graphql-tag package/input.js",
    "content": "import gql, { other } from 'graphql-tag';\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/preserves other imports from graphql-tag package/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/preserves other imports from graphql-tag package/output.mjs",
    "content": "import { other } from 'graphql-tag';\nconst foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 15,\n    \"source\": {\n      \"body\": \"query foo {foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/strips ignored characters from source/input.js",
    "content": "import gql from 'graphql-tag';\n\nconst foo = gql`query foo {foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/strips ignored characters from source/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\",\n      {\n        \"strip\": true\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/strips ignored characters from source/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"name\": {\n      \"kind\": \"Name\",\n      \"value\": \"foo\"\n    },\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 14,\n    \"source\": {\n      \"body\": \"query foo{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/transpiles a single unnamed query/input.js",
    "content": "import gql from 'graphql-tag';\n\nconst foo = gql`{foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/transpiles a single unnamed query/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/transpiles a single unnamed query/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 5,\n    \"source\": {\n      \"body\": \"{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/fixtures/graphql-tag/transpiles a single unnamed query with require/input.js",
    "content": "const gql = require('graphql-tag');\n\nconst foo = gql`{foo}`;\n"
  },
  {
    "path": "test/fixtures/graphql-tag/transpiles a single unnamed query with require/options.json",
    "content": "{\n  \"plugins\": [\n    [\n      \"../../../../src\"\n    ]\n  ]\n}\n"
  },
  {
    "path": "test/fixtures/graphql-tag/transpiles a single unnamed query with require/output.mjs",
    "content": "const foo = {\n  \"kind\": \"Document\",\n  \"definitions\": [{\n    \"kind\": \"OperationDefinition\",\n    \"operation\": \"query\",\n    \"variableDefinitions\": [],\n    \"directives\": [],\n    \"selectionSet\": {\n      \"kind\": \"SelectionSet\",\n      \"selections\": [{\n        \"kind\": \"Field\",\n        \"name\": {\n          \"kind\": \"Name\",\n          \"value\": \"foo\"\n        },\n        \"arguments\": [],\n        \"directives\": []\n      }]\n    }\n  }],\n  \"loc\": {\n    \"start\": 0,\n    \"end\": 5,\n    \"source\": {\n      \"body\": \"{foo}\",\n      \"name\": \"GraphQL request\",\n      \"locationOffset\": {\n        \"line\": 1,\n        \"column\": 1\n      }\n    }\n  }\n};\n"
  },
  {
    "path": "test/index.test.js",
    "content": "const path = require('path');\nconst runner = require(\"@babel/helper-transform-fixture-test-runner\").default;\n\nrunner(\n  __dirname + \"/fixtures\",\n  path.basename(path.dirname(__dirname)),\n  {},\n  { sourceType: 'module' },\n);\n"
  },
  {
    "path": "test/package.json",
    "content": "{\n  \"name\": \"bar\",\n  \"version\": \"1.0.0\"\n}\n"
  },
  {
    "path": "test/unnamed-query.test.js",
    "content": "import {transform} from '@babel/core';\nimport assert from 'assert';\n\nconst fixture = `\n  import gql from 'graphql-tag';\n  gql\\`type Widget { name: String } query {widget}\\`;\n`;\n\ndescribe('When given an unnamed query', () => {\n  let originalError;\n\n  beforeEach(function() {\n    originalError = console.error;\n  });\n\n  afterEach(function() {\n    console.error = originalError;\n  });\n\n  it('fails when there are other definitions', () => {\n    const calls = [];\n\n    console.error = (...args) => calls.push(args.join(' '));\n\n    transform(fixture, {\n      plugins: [['./src']],\n    });\n\n    assert.equal(calls.length, 1);\n    assert.equal(calls[0], 'error Error: GraphQL query must have name.');\n  });\n});\n"
  }
]