quicktype icon indicating copy to clipboard operation
quicktype copied to clipboard

How to convert graphql to json-schema?

Open sarink opened this issue 5 years ago • 2 comments

Is this possible? I can't seem to figure it out

Input:

# test.graphql
type Foo {
  required: String!
  optional: String
}
quicktype --src test.graphql --src-lang graphql --lang schema --out test-json-schema.json

Yields:

Error: Please specify a GraphQL schema with --graphql-schema or --graphql-introspect

So, I tried also giving quicktype my entire schema (although I only want the above test.graphql, I'm not sure why quicktype would require the entire schema for this operation?):

quicktype --src test.graphql --src-lang graphql --graphql-schema codegen/schema.json --lang schema --out test-json-schema.json

And that yielded:

Error: Cannot read property '__schema' of undefined.

My codegen/schema.json file is the result of an introspection query (generated by graphql-code-generator) and definitely does have a top-level __schema key, so I'm not sure why this is happening.

sarink avatar May 25 '20 22:05 sarink