Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
graphql-to-js-client-builder
Advanced tools
Readme
This is a generic function that will take in a GraphQL AST, and produce a javascript AST or code representing the query builder syntax used by graphql-js-client.
$ yarn add graphql-to-js-client-builder
There are two ways to use this package. The simplest way is to call the default export from the main package file. It receives GraphQL code, and variable names, and returns javascript. More complex use cases exist, such as integrating the generated code into other code. This requires a function that returns a javascript AST. See both examples below.
The following example takes GraphQL code, and returns javascript, utilizing graphql-js-client
's query builder syntax.
import transform from 'graphql-to-js-client-builder';
const code = transform(`
query ($id: ID!) {
node(id: $id) {
... on Product {
name
price
}
}
}`, 'client', 'document', 'spreads');
The above code will generate the following javascript:
const document = client.document();
document.addQuery([client.variable('id', 'ID!')], root => {
root.add("node", {
args: {
id: client.variable("ID")
}
}, node => {
node.addFragment('Product', Product => {
Product.add('name');
Product.add('price');
});
});
});
The following example takes GraphQL code, and returns a babel AST, utilizing graphql-js-client
's query builder syntax.
import {transformToAst} from 'graphql-to-js-client-builder';
const ast = transformToAst(`
query ($id: ID!) {
node(id: $id) {
... on Product {
name
price
}
}
}`, {
clientVar: 'client',
documentVar: 'document',
spreandsVar: 'spreads',
variablesVar: 'variables'
}
The above code would return an AST representing the same javascript code that was shown in the previous example.
MIT, see [LICENSE.md](http://github.com/Shopify/graphql-to js-client-builder/blob/master/LICENSE.md) for details.
FAQs
convert raw graphql syntax to graphql-js-client query builder javascript code
The npm package graphql-to-js-client-builder receives a total of 126 weekly downloads. As such, graphql-to-js-client-builder popularity was classified as not popular.
We found that graphql-to-js-client-builder 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.