Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@manifoldco/graphql-gen
Advanced tools
Node client for generating crude GraphQL specs from Swagger OpenAPI.
Node client for generating crude GraphQL specs from Swagger OpenAPI.
💅 Prettifies output via Prettier.
GraphQL Features | |
---|---|
Enum | ✅ |
ID | ✅ |
Implements (allOf ) | ✅ |
Non-nullable | ✅ |
Primitives (string, boolean, number) | ✅ |
Query | 🚫 |
Mutation | 🚫 |
npx @manifoldco/graphql-gen schema.yaml --output schema.graphql
# 🚀 schema.yaml -> schema.graphql [2ms]
This will save a schema.graphql
file in the current folder. The CLI can
accept YAML or JSON for the input file.
npm i --save-dev @manifoldco/graphql-gen
const graphqlGen = require('@manifoldco/graphql-gen');
graphqlGen(spec, [options]);
spec
must be in JSON format. For an example of converting YAML to JSON, see
the generate.js script.
Name | Default | Description |
---|---|---|
output | (stdout) | Where should the output file be saved? |
swagger | 2 | Which Swagger version to use. Currently only supports 2 . |
That didn’t work for our Swagger 2.0 specs 🤷. While normally a PR is the best course of action, this repo exists because it was less effort to build something that works for us than rewrite a popular library (it wasn’t a quick fix).
While it’s possible to generate something from OpenAPI, it’s intentionally omitted from autogeneration here. Queries and Mutations are best left up to humans, so you can determine what developers should access, and how. Ultimately generating these will always fall short of how real humans could—and should—use your GraphQL endpoint.
GraphQL is a spec, just like OpenAPI. For this reason, automatic generation isn’t ideal long-term. This library should probably be used as a first-pass to migrate an OpenAPI endpoint to GraphQL. This can generate types, but can’t intelligently generate the best queries and mutations for your specific endpoint.
A common example of this: Swagger has a concept of format: datetime
.
GraphQL cares about this, but doesn’t assume the formatting. Is this UNIX
time? ISO? Are there timezones? Types can be so much more descriptive than
mere string
or int
, and GraphQL gives you the tools to declare this
yourself.
FAQs
Generate GraphQL schemas from Swagger OpenAPI specs
The npm package @manifoldco/graphql-gen receives a total of 13 weekly downloads. As such, @manifoldco/graphql-gen popularity was classified as not popular.
We found that @manifoldco/graphql-gen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 18 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.