New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gql2ts/from-schema

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gql2ts/from-schema

convert a graphql schema to typescript interfaces

  • 2.0.0-4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@gql2ts/from-schema

This package is used to generate a namespace for a GraphQL Schema with all possible interfaces/types included.

Objective

Pass a GraphQL type schema and query to generate a TypeScript interface:

Input:

type Query {
  thing: String!
  anotherThing: Boolean!
}
query GetThing {
  thing
}

Output:

interface GetThing {
  thing: string;
}

Basic Usage

import { generateNamespace } from '@gql2ts/from-schema';
import { schema } from 'my-graphql-stuff';
import * as fs from 'fs';

const myNamespace = generateNamespace('MyGraphQL', schema);
fs.writeFile('mySchema.d.ts', myNamespace);

Advanced Usage

import { generateNamespace, ISchemaToInterfaceOptions } from '@gql2ts/from-schema';
import { schema } from 'my-graphql-stuff';
import { IFromQueryOptions } from '@gql2ts/types';
import * as fs from 'fs';

const options: Partial<ISchemaToInterfaceOptions> = {
  ignoredTypes: ['BadGraphType']
};

const overrides: Partial<IFromQueryOptions> = {
  generateInterfaceName: name => `IGraphQL${name}`
};

const myNamespace = generateNamespace('MyGraphQL', schema, options, overrides);
fs.writeFile('mySchema.d.ts', myNamespace);

Keywords

FAQs

Package last updated on 13 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc