How to use the graphql-2-json-schema.fromIntrospectionQuery function in graphql-2-json-schema

To help you get started, we’ve selected a few graphql-2-json-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frontier-forms / frontier-forms / lib / data / graphql.ts View on Github external
return props.client.query({ query: introspectionQuery }).then(result => {
        if (result.errors) {
          // tslint:disable-next-line no-console
          console.log(`Unable to fetch GraphQL schema: ${result.errors}`);
          return null;
        } else {
          const schema = fromIntrospectionQuery(result.data) as JSONSchema7;
          // FIXME: update "graphql-2-json-schema" to generate JSONSchema7
          schema.$schema = 'http://json-schema.org/draft-07/schema#';
          return {
            schema: schemaWithFormats(buildFormSchema(schema, mutationName), props.formats || {}),
            mutationName
          };
        }
      });
    } else {
github wittydeveloper / react-apollo-form / lib / cli.ts View on Github external
// ------
                console.log('[2/3] generate mutations enum type ...');

                const mutationNames = extractMutationsNamesFromFile(path.resolve(outputPath, 'schema.json'));
                if (mutationNames) {
                    fs.writeFileSync(
                        path.resolve(outputPath, 'mutations.d.ts'),
                        generateMutationTypesDef(mutationNames)
                    );
                } else {
                    console.error('Failed to generate mutations typing');
                }
                // ------
                console.log('[3/3] generate json schema file ...');

                const jsonSchemaObj = fromIntrospectionQuery(
                    JSON.parse(fs.readFileSync(path.resolve(outputPath, 'schema.json')).toString()).data
                );

                fs.writeFileSync(
                    path.resolve(outputPath, 'apollo-form-json-schema.json'),
                    JSON.stringify(jsonSchemaObj)
                );
            } catch (error) {
                console.error(error);
            }

            console.log('Done.');
        }
    )
github wittydeveloper / react-apollo-form / stories / index.tsx View on Github external
import { fromIntrospectionQuery } from 'graphql-2-json-schema';
import gql from 'graphql-tag';
import { JSONSchema6 } from 'json-schema';
import { keys } from 'lodash';
import * as React from 'react';
import { ApolloConsumer } from 'react-apollo';
import { FieldProps } from 'react-jsonschema-form';
import { schema as mockSchema } from '../graphql-mock';
import { configure, ApolloFormConfigureTheme } from '../lib/forms/component';
import { ErrorListComponent } from '../lib/forms/renderers';
import { ReactJsonschemaFormError } from '../lib/forms/utils';
const { Button, Input, Checkbox, Header, Form, Message } = require('semantic-ui-react');
const { withKnobs, select, boolean: bool } = require('@storybook/addon-knobs/react');

const introspection = graphqlSync(mockSchema, introspectionQuery).data as IntrospectionQuery;
const jsonSchema = fromIntrospectionQuery(introspection);
const document = gql`
    mutation createTodo($todo: TodoInputType!) {
        create_todo(todo: $todo) {
            id
        }
    }
`;

const ErrorList: ErrorListComponent = p => (
     e.message)}
    />
);

graphql-2-json-schema

`graphql-2-json-schema` package

MIT
Latest version published 1 year ago

Package Health Score

51 / 100
Full package analysis

Popular graphql-2-json-schema functions

Similar packages