GraphQL Tag Pluck
graphql-tag-pluck
will take JavaScript code as an input and will pluck all template literals provided to graphql-tag
.
Input:
const fragment = gql` fragment Foo on FooType { id }` const doc = gql` query foo { foo { ...Foo } } `
Output:
fragment Foo on FooType { id} query foo { foo { ...Foo }}
Originally created because of https://graphql-code-generator.com/.
Usage
graphql-tag-pluck
is installable via NPM (or Yarn):
$ npm install graphql-tag-pluck
Once installed you can pluck GraphQL template literals using one of the following methods:
// Returns promisegqlPluck // Returns stringgqlPluckfromFile // Returns stringgqlPluck
supported file extensions are: .js
, .jsx
, .ts
, .tsx
, .flow
, .flow.js
, .flow.jsx
, .graphqls
, .graphql
, .gqls
, .gql
.
License
MIT