Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@graphql-codegen/schema-ast
Advanced tools
GraphQL Code Generator plugin for generating a .graphql file from a given schema
@graphql-codegen/schema-ast is a plugin for GraphQL Code Generator that allows you to generate a GraphQL schema in AST (Abstract Syntax Tree) format. This can be useful for various purposes such as schema analysis, transformation, and validation.
Generate GraphQL Schema AST
This feature allows you to generate the AST representation of a GraphQL schema. The code sample demonstrates how to use the @graphql-codegen/schema-ast plugin to generate the AST from a simple GraphQL schema.
const { generate } = require('@graphql-codegen/schema-ast');
const schema = `
type Query {
hello: String
}
`;
const config = {
filename: 'schema.graphql',
schema: schema,
plugins: [
{
'schema-ast': {}
}
],
pluginMap: {
'schema-ast': require('@graphql-codegen/schema-ast')
}
};
generate(config).then(output => {
console.log(output);
});
Customizing Output
This feature allows you to customize the output of the generated AST. The code sample shows how to enable comment descriptions in the generated AST.
const { generate } = require('@graphql-codegen/schema-ast');
const schema = `
type Query {
hello: String
}
`;
const config = {
filename: 'schema.graphql',
schema: schema,
plugins: [
{
'schema-ast': {
commentDescriptions: true
}
}
],
pluginMap: {
'schema-ast': require('@graphql-codegen/schema-ast')
}
};
generate(config).then(output => {
console.log(output);
});
graphql-tools is a set of utilities from Apollo for building and manipulating GraphQL schemas. It includes features for schema stitching, schema transforms, and more. While @graphql-codegen/schema-ast focuses on generating ASTs, graphql-tools offers a broader range of schema manipulation capabilities.
graphql-code-generator is a tool for generating code from GraphQL schemas and operations. It supports a wide range of plugins for different languages and frameworks. @graphql-codegen/schema-ast is one of the plugins available for graphql-code-generator, specifically for generating ASTs.
FAQs
GraphQL Code Generator plugin for generating a .graphql file from a given schema
The npm package @graphql-codegen/schema-ast receives a total of 2,783,721 weekly downloads. As such, @graphql-codegen/schema-ast popularity was classified as popular.
We found that @graphql-codegen/schema-ast demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.