
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
babel-plugin-graphql-js-client-transform
Advanced tools
Babel plugin for transforming raw GraphQL queries into graphql-js-client query builder syntax
This Babel plugin will transform any tagged raw GraphQL query to Shopify/graphql-js-client query builder syntax.
$ yarn add babel-plugin-graphql-js-client-transform
.babelrc
{
"plugins": [
"graphql-js-client-transform"
]
}
// Finds template literals tagged with gql
import {gql} from 'babel-plugin-graphql-js-client-transform';
// Finds template literals tagged with customTagName
import {gql as customTagName} from 'babel-plugin-graphql-js-client-transform';
The plugin will pick up any template literals tagged with the imported gql
function.
Do not reassign the function to another variable after it has been imported.
import {gql} from 'babel-plugin-graphql-js-client-transform';
...
const newTag = gql;
newTag(client)`...`; // Don't do this. This template literal won't be transformed.
An instance of Shopify/graphql-js-client must be supplied to the tag.
The following are example usages.
Convert a simple query.
import {gql} from 'babel-plugin-graphql-js-client-transform';
...
client.send(gql(client)`
query {
shop {
name
}
}
`);
import {gql} from 'babel-plugin-graphql-js-client-transform';
...
const _document = client.document(); // Creates a document to store the query
_document.addQuery((root) => {
root.add('shop', (shop) => {
shop.add('name');
});
});
client.send(_document);
The query can also be stored inside a variable instead of being sent directly.
import {gql} from 'babel-plugin-graphql-js-client-transform';
...
const query = gql(client)`
query {
shop {
name
}
}
`;
client.send(query);
import {gql} from 'babel-plugin-graphql-js-client-transform';
...
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);
MIT, see LICENSE.md for details.
FAQs
Babel plugin for transforming raw GraphQL queries into graphql-js-client query builder syntax
The npm package babel-plugin-graphql-js-client-transform receives a total of 100 weekly downloads. As such, babel-plugin-graphql-js-client-transform popularity was classified as not popular.
We found that babel-plugin-graphql-js-client-transform demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.