Extracts GraphQL query/mutation/fragment strings from JavaScript/TypeScript template literals tagged with `graphql-tag` or magic comments like `/* GraphQL */`. Version 0.8.7 — pre-1.0, maintained infrequently. Key differentiator: it powers tools like GraphQL Code Generator to statically extract GraphQL strings for schema validation, codegen, or testing without executing the JS.
npm install graphql-tag-pluckNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Plucks GraphQL operations from a code string containing gql tagged templates. Shows async usage with options.
Use gqlPluck.fromFile.sync(filePath) or await the promise from gqlPluck.fromFile.
Always use block comment `/* GraphQL */` or configure the magic comment name via options.
Post-process with a GraphQL validator (e.g., graphql's parse or validation) to ensure correctness.
Add an entry to modules with `name: 'my-global'` and `identifier: 'graphql'` to ensure proper detection.
npm install @babel/parser @babel/traverse @babel/types
Ensure the code is valid and set correct fileExt option (e.g., '.tsx' for TSX).
Use named import: import { gqlPluckFromFile } from 'graphql-tag-pluck'