@stackworx/relay-extractor
v0.0.3
Published
Relay Query Extractor for Testing
Readme
Read Me
This project is meant to extract all the GraphQL operations from a relay project and clean them so that a client can be generated
CLI Usage
Extract operations from a source folder to an output directory. Optionally provide a schema (SDL or introspection JSON) and exclude subscriptions.
npx @stackworx/relay-extractor \
--src ./src \
--out ./out \
--schema ./schema.graphql \
--exclude-subscriptions--exclude-subscriptions: When set, subscription operations are skipped and not written to the output.
Issues
- Remove Relay Compiler Directives
- Remove Relay Interla fields (
__id) - Handle missing arguments that relay handles with
argumentDefinitions
Testing: Vitest + GraphQL fix
Background: When running Vitest with GraphQL-related tooling, you may see errors like: "Cannot use GraphQLSchema ... from another module or realm" due to how module resolution handles
graphqlsubpath imports.Fix: Add aliases so Vitest resolves the ESM entry points consistently. This is configured in
vitest.config.ts:import { defineConfig } from 'vitest/config' export default defineConfig({ resolve: { alias: { 'graphql/language/printer': 'graphql/language/printer.js', 'graphql/language': 'graphql/language/index.js', graphql: 'graphql/index.js', }, }, })Reference: https://github.com/vitest-dev/vitest/issues/4605#issuecomment-1847658160
Run tests:
npm run test -- --run
