Skip to content

Commit

Permalink
Add explicitResourceManagement to the list of parser plugins in graph…
Browse files Browse the repository at this point in the history
…ql-tag-pluck (#5920)

* Add explicitResourceManagement to the list of parser plugins in graphql-tag-pluck

* Create changeset for @graphql-tools/graphql-tag-pluck
  • Loading branch information
collin committed Feb 21, 2024
1 parent 7f606ea commit f0edcb2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-paws-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-tools/graphql-tag-pluck": minor
---

Adds support for tc39/proposal-explicit-resource-management ('using' keyword)
1 change: 1 addition & 0 deletions packages/graphql-tag-pluck/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function generateConfig(
'decorators-legacy',
'doExpressions',
'dynamicImport',
'explicitResourceManagement',
'exportDefaultFrom',
'exportNamespaceFrom',
'functionBind',
Expand Down
41 changes: 41 additions & 0 deletions packages/graphql-tag-pluck/tests/graphql-tag-pluck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,47 @@ describe('graphql-tag-pluck', () => {
);
});

it.only("should pluck graphql-tag template literals from .ts that use 'using' keyword", async () => {
const sources = await pluck(
'tmp-XXXXXX.ts',
freeText(`
import { graphql } from '../somewhere'
import { Document } from 'graphql'
import createManagedResource from 'managed-resource'
using managedResource = createManagedResource()
const fragment: Document = graphql(\`
fragment Foo on FooType {
id
}
\`)
const doc: Document = graphql(\`
query foo {
foo {
...Foo
}
}
\`)
`),
);

expect(sources.map(source => source.body).join('\n\n')).toEqual(
freeText(`
fragment Foo on FooType {
id
}
query foo {
foo {
...Foo
}
}
`),
);
});

it('should pluck graphql-tag template literals from .ts file', async () => {
const sources = await pluck(
'tmp-XXXXXX.ts',
Expand Down

0 comments on commit f0edcb2

Please sign in to comment.