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.
graphql-2-json-schema
Advanced tools
graphql-2-json-schema
package
Transform a GraphQL Schema introspection file to a valid JSON Schema.
import {
graphqlSync,
introspectionQuery,
IntrospectionQuery
} from 'graphql';
import { fromIntrospectionQuery } from 'graphql-2-json-schema';
// schema is your GraphQL schema.
const introspection = graphqlSync(schema, introspectionQuery).data as IntrospectionQuery;
const result = fromIntrospectionQuery(introspection);
type Todo {
id: String!
name: String!
completed: Boolean
color: Color
}
input TodoInputType {
name: String!
completed: Boolean
color: Color
}
enum Color {
"Red color"
RED
"Green color"
GREEN
}
type Query {
todo(id: String!): Todo
todos: [Todo]
}
type Mutation {
update_todo(id: String!, todo: TodoInputType!): Todo
create_todo(todo: TodoInputType!): Todo
}
{
$schema: 'http://json-schema.org/draft-06/schema#',
properties: {
Query: {
type: 'object',
properties: {
todo: {
type: 'object',
properties: {
arguments: {
type: 'object',
properties: {
id: { type: 'string' }
},
required: ['id']
},
return: {
$ref: '#/definitions/Todo'
}
},
required: []
},
todos: {
type: 'object',
properties: {
arguments: {
type: 'object',
properties: {},
required: []
},
return: {
type: 'array',
items: { $ref: '#/definitions/Todo' }
}
},
required: []
}
},
required: []
},
Mutation: {
type: 'object',
properties: {
update_todo: {
type: 'object',
properties: {
arguments: {
type: 'object',
properties: {
id: { type: 'string' },
todo: { $ref: '#/definitions/TodoInputType' }
},
required: ['id', 'todo']
},
return: {
$ref: '#/definitions/Todo'
}
},
required: []
},
create_todo: {
type: 'object',
properties: {
arguments: {
type: 'object',
properties: {
todo: { $ref: '#/definitions/TodoInputType' }
},
required: ['todo']
},
return: {
$ref: '#/definitions/Todo'
}
},
required: []
}
}
},
},
definitions: {
'Todo': {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
completed: { type: 'boolean' },
color: { $ref: '#/definitions/Color' },
},
required: ['id', 'name']
},
'Color': {
type: 'string',
anyOf: [
{
enum: ['RED'],
title: 'Red color',
},
{
enum: ['GREEN'],
title: 'Green color',
}
]
},
'TodoInputType': {
type: 'object',
properties: {
name: { type: 'string' },
completed: { type: 'boolean' },
color: { $ref: '#/definitions/Color' },
},
required: ['name']
}
}
}
FAQs
`graphql-2-json-schema` package
The npm package graphql-2-json-schema receives a total of 2,552 weekly downloads. As such, graphql-2-json-schema popularity was classified as popular.
We found that graphql-2-json-schema 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.
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.