Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
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
"A field that requires an argument"
colors(filter: [Color!]!): [Color!]!
}
input TodoInputType {
name: String!
completed: Boolean
color: Color=RED
}
enum Color {
"Red color"
RED
"Green color"
GREEN
}
type Query {
"A Query with 1 required argument and 1 optional argument"
todo(id: String!, isCompleted: Boolean=false): Todo
todos: [Todo]
}
type Mutation {
"A Mutation with 1 required argument"
create_todo(todo: TodoInputType!): Todo
"A Mutation with 2 required arguments"
update_todo(id: String!, todo: TodoInputType!): Todo
}
{
'$schema': 'http://json-schema.org/draft-06/schema#',
properties: {
Query: {
type: 'object',
properties: {
todo: {
description: 'A Query with 1 required argument and 1 optional argument',
type: 'object',
properties: {
return: { '$ref': '#/definitions/Todo' },
arguments: {
type: 'object',
properties: {
id: { '$ref': '#/definitions/String', type: 'string' },
isCompleted: {
'$ref': '#/definitions/Boolean',
type: 'boolean',
default: false
}
},
required: [ 'id' ]
}
},
required: []
},
todos: {
type: 'object',
properties: {
return: { type: 'array', items: { '$ref': '#/definitions/Todo' } },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
}
},
required: []
},
Mutation: {
type: 'object',
properties: {
create_todo: {
description: 'A Mutation with 1 required argument',
type: 'object',
properties: {
return: { '$ref': '#/definitions/Todo' },
arguments: {
type: 'object',
properties: { todo: { '$ref': '#/definitions/TodoInputType' } },
required: [ 'todo' ]
}
},
required: []
},
update_todo: {
description: 'A Mutation with 2 required arguments',
type: 'object',
properties: {
return: { '$ref': '#/definitions/Todo' },
arguments: {
type: 'object',
properties: {
id: { '$ref': '#/definitions/String', type: 'string' },
todo: { '$ref': '#/definitions/TodoInputType' }
},
required: [ 'id', 'todo' ]
}
},
required: []
}
},
required: []
}
},
definitions: {
Todo: {
type: 'object',
properties: {
id: {
type: 'object',
properties: {
return: { '$ref': '#/definitions/String', type: 'string' },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
},
name: {
type: 'object',
properties: {
return: { '$ref': '#/definitions/String', type: 'string' },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
},
completed: {
type: 'object',
properties: {
return: { '$ref': '#/definitions/Boolean', type: 'boolean' },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
},
color: {
type: 'object',
properties: {
return: { '$ref': '#/definitions/Color' },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
},
colors: {
description: 'A field that requires an argument',
type: 'object',
properties: {
return: { type: 'array', items: { '$ref': '#/definitions/Color' } },
arguments: {
type: 'object',
properties: {
filter: {
type: 'array',
items: { '$ref': '#/definitions/Color' }
}
},
required: [ 'filter' ]
}
},
required: []
}
},
required: [ 'id', 'name', 'colors' ]
},
TodoInputType: {
type: 'object',
properties: {
name: { '$ref': '#/definitions/String', type: 'string' },
completed: { '$ref': '#/definitions/Boolean', type: 'boolean' },
color: { '$ref': '#/definitions/Color', default: 'RED' }
},
required: [ 'name' ]
},
Color: {
type: 'string',
anyOf: [
{
description: 'Red color',
enum: [ 'RED' ],
title: 'Red color'
},
{
description: 'Green color',
enum: [ 'GREEN' ],
title: 'Green color'
}
]
},
String: {
description: 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.',
type: 'string',
title: 'String'
},
Boolean: {
description: 'The `Boolean` scalar type represents `true` or `false`.',
type: 'boolean',
title: 'Boolean'
}
}
}
FAQs
`graphql-2-json-schema` package
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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.