Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-ast-types-browser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-ast-types-browser

:warning: This package is a temporary clone of [`graphql-ast-types`](https://www.npmjs.com/package/graphql-ast-types). It will be deleted as soon as the issue [#7](https://github.com/imranolas/graphql-ast-types/issues/7) is closed.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
decreased by-60.87%
Maintainers
1
Weekly downloads
 
Created
Source

:warning: This package is a temporary clone of graphql-ast-types. It will be deleted as soon as the issue #7 is closed.

Use it at your own risk.

graphql-ast-types

Autogenerated helper functions for generating a GraphQL AST

This project generates helpers functions from the graphql/language AST flow descriptions. It is intended to help with building a valid GraphQL AST.

Getting Started

yarn add graphql-ast-types

import * as t from 'graphql-ast-types';

The implementation here mimics that of babel-types. Thanks Babel team.

Usage

The following is an example of how to build a simple query with AST types.

import * as t from 'graphql-ast-types';
import { print } from 'graphql/language';

const ast = t.document([
  t.operationDefinition(
    'query',
    t.selectionSet([
      t.field(t.name('foo')),
      t.field(t.name('bar'))
    ])
  )
]);

print(ast);

/*
query {
  foo
  bar
}
*/

In addition, method calls are validated for correctness and accompanied by is and assert helpers.

t.isName(t.name('Hello')); // true

t.isName({ kind: 'Name' }); // true
t.assert({ kind: 'Name' }); // no error

t.isName({ kind: 'IntValue' }); // false
t.assert({ kind: 'IntValue' }); // error

The full API can be found here.

Keywords

FAQs

Package last updated on 30 Oct 2018

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