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

babel-plugin-graphql-js-client-transform

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-graphql-js-client-transform

Babel plugin for transforming raw GraphQL queries into graphql-js-client query builder syntax

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65
increased by14.04%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-graphql-js-client-transform

This Babel plugin will transform any tagged raw GraphQL query to Shopify/graphql-js-client query builder syntax.

Table Of Contents

Installation

$ yarn add babel-plugin-graphql-js-client-transform

In your .babelrc

{
  "plugins": [
    "graphql-js-client-transform"
  ]
}

By default, the plugin will search for the tag gql. This value is configurable by passing in a tag option to the plugin.

{
  "plugins": [
    ["graphql-js-client-transform", {"tag": "customTag"}]
  ]
}

Usage

Simply tag your raw GraphQL queries and the plugin will transform them. An instance of Shopify/graphql-js-client must be supplied to the tag.

Examples

The following are example usages with the default variable name.

Example 1

Convert a simple query.

Source Code
client.send(gql(client)`
  query {
    shop {
      name
    }
  }
`);
Transformed Code
const _document = client.document(); // Creates a document to store the query
_document.addQuery((root) => {
  root.add('shop', (shop) => {
     shop.add('name');
  });
});

client.send(_document);
Example 2

The query can also be stored inside a variable instead of being sent directly.

Source Code
const query = gql(client)`
  query {
    shop {
      name
    }
  }
`;

client.send(query);
Transformed Code
const _document = client.document(); // Creates a document to store the query
_document.addQuery((root) => {
  root.add('shop', (shop) => {
     shop.add('name');
  });
});

const query = _document;

client.send(query);

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Package last updated on 11 Apr 2017

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