Skip to content

Commit

Permalink
Merge pull request #13 from darkbasic/apollo-server-express
Browse files Browse the repository at this point in the history
Add support for apollo-server-express
  • Loading branch information
DAB0mB authored Mar 7, 2019
2 parents 30cfeae + 15d90aa commit 5391803
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
node_modules
npm-debug.log
.idea
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ I recommend you to look at the [source code](src/visitor.js) for a clearer under

- **`modules`**

An array of packages that are responsible for exporting the GraphQL string parser function. By default it supports `graphql-tag` and `gatsby`.
An array of packages that are responsible for exporting the GraphQL string parser function. By default it supports `graphql-tag`, `gatsby` and `apollo-server-express`.

```js
{
Expand All @@ -124,6 +124,11 @@ I recommend you to look at the [source code](src/visitor.js) for a clearer under
name: 'gatsby',
identifier: 'graphql',
},
{
// import { gql } from 'apollo-server-express'
name: 'apollo-server-express',
identifier: 'gql',
},
]
}
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-tag-pluck",
"version": "0.6.0",
"version": "0.7.0",
"description": "Pluck graphql-tag template literals",
"license": "MIT",
"repository": "https://github.com/DAB0mB/graphql-tag-pluck.git",
Expand Down
41 changes: 41 additions & 0 deletions src/graphql-tag-pluck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,4 +878,45 @@ describe('graphql-tag-pluck', () => {
}
`))
})

it('should pluck gql template literal from apollo-server-express package', async () => {
const file = await tmp.file({
unsafeCleanup: true,
template: '/tmp/tmp-XXXXXX.js',
})

await fs.writeFile(file.name, freeText(`
import { gql } from 'apollo-server-express'
const fragment = gql(\`
fragment Foo on FooType {
id
}
\`)
const doc = gql\`
query foo {
foo {
...Foo
}
}
\${fragment}
\`
`))

const gqlString = await gqlPluck.fromFile(file.name)

expect(gqlString).toEqual(freeText(`
fragment Foo on FooType {
id
}
query foo {
foo {
...Foo
}
}
`))
})
})
4 changes: 4 additions & 0 deletions src/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const defaults = {
name: 'gatsby',
identifier: 'graphql',
},
{
name: 'apollo-server-express',
identifier: 'gql'
},
],
gqlMagicComment: 'graphql',
}
Expand Down

0 comments on commit 5391803

Please sign in to comment.