Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump schema in IDL format #78

Open
acro5piano opened this issue Jun 23, 2024 · 0 comments
Open

Dump schema in IDL format #78

acro5piano opened this issue Jun 23, 2024 · 0 comments

Comments

@acro5piano
Copy link

acro5piano commented Jun 23, 2024

Hi, thank you for the great library. It helps my life a lot.

Do you have a plan to dump IDL schema?

I'm using gqtx along with the awesome graphql-code-generator. To generate GraphQL query, I need schema.graphql file (Network request also works but I prefer to omit dependent services for code generation). Also, a static schema file will help other developers to understand overall API.

I've written the below script to dump schema in my current project. It would be great if dumping a schema is officially supported:

import { buildGraphQLSchema } from 'gqtx'

import { printSchemaWithDirectives } from '@graphql-tools/utils'
import { writeFileSync } from 'node:fs'
import { QueryType } from './types/Query'

export const schema = buildGraphQLSchema({
  query: QueryType,
})

writeFileSync(
  './path/to/schema.graphql',
  printSchemaWithDirectives(schema),
  'utf8',
)

If it's okay I'll try to send a PR. Thanks!

@acro5piano acro5piano changed the title Add a function to dump schema in IDL format Dump schema in IDL format Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant