Skip to content

stackworx/relay-extractor

Repository files navigation

Read Me

CI npm version

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 graphql subpath 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: vitest-dev/vitest#4605 (comment)

  • Run tests:

     npm run test -- --run

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published