Graphql Json Schema

[Solved] Graphql Json Schema | Scala - Code Explorer | yomemimo.com
Question : graphql json schema

Answered by : daschi

import { graphqlSync, getIntrospectionQuery, IntrospectionQuery
} from 'graphql';
import { fromIntrospectionQuery } from 'graphql-2-json-schema';
const options = { // Whether or not to ignore GraphQL internals that are probably not relevant // to documentation generation. // Defaults to `true` ignoreInternals: true, // Whether or not to properly represent GraphQL Lists with Nullable elements // as type "array" with items being an "anyOf" that includes the possible // type and a "null" type. // Defaults to `false` for backwards compatibility, but in future versions // the effect of `true` is likely going to be the default and only way. It is // highly recommended that new implementations set this value to `true`. nullableArrayItems: true
}
// schema is your GraphQL schema.
const introspection = graphqlSync(schema, getIntrospectionQuery()).data as IntrospectionQuery;
const jsonSchema = fromIntrospectionQuery(introspection, options);

Source : https://www.npmjs.com/package/graphql-2-json-schema | Last Update : Tue, 15 Mar 22

Answers related to graphql json schema

Code Explorer Popular Question For Scala