Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-2-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-2-json-schema - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

2

CHANGELOG.md

@@ -5,2 +5,4 @@ # Changelog

## [0.7.0](https://github.com/wittydeveloper/graphql-to-json-schema/compare/v0.6.0...v0.7.0) (2021-07-21)
## [0.6.0](https://github.com/wittydeveloper/graphql-to-json-schema/compare/v0.5.1...v0.6.0) (2021-02-25)

@@ -7,0 +9,0 @@

@@ -21,2 +21,9 @@ "use strict";

type SimpleTodo {
id: String!
name: String!
}
union TodoUnion = Todo | SimpleTodo
input TodoInputType {

@@ -45,3 +52,3 @@ name: String!

todos(
"Reauired argument that is a list that cannot contain null values"
"Required argument that is a list that cannot contain null values"
ids: [String!]!

@@ -48,0 +55,0 @@ ): [Todo]

@@ -70,2 +70,7 @@ "use strict";

}
else if (typeGuards_1.isIntrospectionUnionType(curr)) {
acc[curr.name] = {
oneOf: curr.possibleTypes.map((type) => typesMapping_1.graphqlToJSONType(type, options)),
};
}
else if (typeGuards_1.isIntrospectionEnumType(curr)) {

@@ -72,0 +77,0 @@ acc[curr.name] = {

3

dist/lib/typeGuards.d.ts

@@ -1,2 +0,2 @@

import { IntrospectionEnumType, IntrospectionField, IntrospectionInputObjectType, IntrospectionInputTypeRef, IntrospectionInputValue, IntrospectionListTypeRef, IntrospectionNamedTypeRef, IntrospectionNonNullTypeRef, IntrospectionObjectType, IntrospectionOutputTypeRef, IntrospectionSchema, IntrospectionType, IntrospectionTypeRef, IntrospectionScalarType } from 'graphql';
import { IntrospectionEnumType, IntrospectionField, IntrospectionInputObjectType, IntrospectionInputTypeRef, IntrospectionInputValue, IntrospectionListTypeRef, IntrospectionNamedTypeRef, IntrospectionNonNullTypeRef, IntrospectionObjectType, IntrospectionOutputTypeRef, IntrospectionSchema, IntrospectionType, IntrospectionTypeRef, IntrospectionUnionType, IntrospectionScalarType } from 'graphql';
export declare const isIntrospectionField: (type: IntrospectionField | IntrospectionInputValue) => type is IntrospectionField;

@@ -8,2 +8,3 @@ export declare const isIntrospectionInputValue: (type: IntrospectionField | IntrospectionInputValue) => type is IntrospectionInputValue;

export declare const isIntrospectionEnumType: (type: IntrospectionSchema['types'][0]) => type is IntrospectionEnumType;
export declare const isIntrospectionUnionType: (type: IntrospectionSchema['types'][0]) => type is IntrospectionUnionType;
export declare const isNonNullIntrospectionType: (type: IntrospectionTypeRef) => type is IntrospectionNonNullTypeRef<IntrospectionNamedTypeRef<IntrospectionType>>;

@@ -10,0 +11,0 @@ export declare const isIntrospectionScalarType: (type: IntrospectionSchema['types'][0]) => type is IntrospectionScalarType;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterDefinitionsTypes = exports.isIntrospectionDefaultScalarType = exports.isIntrospectionScalarType = exports.isNonNullIntrospectionType = exports.isIntrospectionEnumType = exports.isIntrospectionInputObjectType = exports.isIntrospectionObjectType = exports.isIntrospectionListTypeRef = exports.isIntrospectionInputValue = exports.isIntrospectionField = void 0;
exports.filterDefinitionsTypes = exports.isIntrospectionDefaultScalarType = exports.isIntrospectionScalarType = exports.isNonNullIntrospectionType = exports.isIntrospectionUnionType = exports.isIntrospectionEnumType = exports.isIntrospectionInputObjectType = exports.isIntrospectionObjectType = exports.isIntrospectionListTypeRef = exports.isIntrospectionInputValue = exports.isIntrospectionField = void 0;
const lodash_1 = require("lodash");

@@ -17,2 +17,4 @@ const isIntrospectionField = (type) => lodash_1.has(type, 'args');

exports.isIntrospectionEnumType = isIntrospectionEnumType;
const isIntrospectionUnionType = (type) => type.kind === 'UNION';
exports.isIntrospectionUnionType = isIntrospectionUnionType;
const isNonNullIntrospectionType = (type) => type.kind === 'NON_NULL';

@@ -30,2 +32,3 @@ exports.isNonNullIntrospectionType = isNonNullIntrospectionType;

(exports.isIntrospectionEnumType(type) && !!type.enumValues) ||
(exports.isIntrospectionUnionType(type) && !!type.possibleTypes) ||
(exports.isIntrospectionScalarType(type) && !!type.name)) &&

@@ -32,0 +35,0 @@ (!ignoreInternals || (ignoreInternals && !lodash_1.startsWith(type.name, '__'))));

@@ -40,2 +40,11 @@ "use strict";

"A simpler ToDo Object"
type SimpleTodo {
id: String!
name: String!
}
"A Union of Todo and SimpleTodo"
union TodoUnion = Todo | SimpleTodo
"""

@@ -352,2 +361,25 @@ A type that describes ToDoInputType. Its description might not

},
SimpleTodo: {
type: 'object',
description: 'A simpler ToDo Object',
properties: {
id: {
type: 'object',
properties: {
return: { $ref: '#/definitions/String' },
arguments: { type: 'object', properties: {}, required: [] },
},
required: [],
},
name: {
type: 'object',
properties: {
return: { $ref: '#/definitions/String' },
arguments: { type: 'object', properties: {}, required: [] },
},
required: [],
},
},
required: ['id', 'name'],
},
Color: {

@@ -378,2 +410,9 @@ type: 'string',

},
TodoUnion: {
description: 'A Union of Todo and SimpleTodo',
oneOf: [
{ $ref: '#/definitions/Todo' },
{ $ref: '#/definitions/SimpleTodo' },
],
},
},

@@ -380,0 +419,0 @@ };

@@ -28,2 +28,9 @@ import { inspect } from 'util'

type SimpleTodo {
id: String!
name: String!
}
union TodoUnion = Todo | SimpleTodo
input TodoInputType {

@@ -52,3 +59,3 @@ name: String!

todos(
"Reauired argument that is a list that cannot contain null values"
"Required argument that is a list that cannot contain null values"
ids: [String!]!

@@ -55,0 +62,0 @@ ): [Todo]

@@ -16,2 +16,3 @@ import {

isIntrospectionObjectType,
isIntrospectionUnionType,
isNonNullIntrospectionType,

@@ -148,2 +149,6 @@ isIntrospectionScalarType,

}
} else if (isIntrospectionUnionType(curr)) {
acc[curr.name] = {
oneOf: curr.possibleTypes.map((type) => graphqlToJSONType(type, options)),
}
} else if (isIntrospectionEnumType(curr)) {

@@ -150,0 +155,0 @@ acc[curr.name] = {

@@ -15,2 +15,3 @@ import {

IntrospectionTypeRef,
IntrospectionUnionType,
IntrospectionScalarType,

@@ -52,2 +53,6 @@ } from 'graphql'

export const isIntrospectionUnionType = (
type: IntrospectionSchema['types'][0]
): type is IntrospectionUnionType => type.kind === 'UNION'
export const isNonNullIntrospectionType = (

@@ -83,2 +88,3 @@ type: IntrospectionTypeRef

(isIntrospectionEnumType(type) && !!type.enumValues) ||
(isIntrospectionUnionType(type) && !!type.possibleTypes) ||
(isIntrospectionScalarType(type) && !!type.name)) &&

@@ -85,0 +91,0 @@ (!ignoreInternals || (ignoreInternals && !startsWith(type.name, '__')))

{
"name": "graphql-2-json-schema",
"version": "0.6.0",
"version": "0.7.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "repository": "git@github.com:wittydeveloper/graphql-to-json-schema.git",

@@ -57,2 +57,9 @@ # GraphQL Schema to JSON Schema [![npm version](https://badge.fury.io/js/graphql-2-json-schema.svg)](https://badge.fury.io/js/graphql-2-json-schema)

type SimpleTodo {
id: String!
name: String!
}
union TodoUnion = Todo | SimpleTodo
input TodoInputType {

@@ -81,3 +88,3 @@ name: String!

todos(
"Reauired argument that is a list that cannot contain null values"
"Required argument that is a list that cannot contain null values"
ids: [String!]!

@@ -153,3 +160,3 @@ ): [Todo]

ids: {
description: 'Reauired argument that is a list that cannot contain null values',
description: 'Required argument that is a list that cannot contain null values',
type: 'array',

@@ -284,2 +291,30 @@ items: { '$ref': '#/definitions/String' }

},
SimpleTodo: {
type: 'object',
properties: {
id: {
type: 'object',
properties: {
return: { '$ref': '#/definitions/String' },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
},
name: {
type: 'object',
properties: {
return: { '$ref': '#/definitions/String' },
arguments: { type: 'object', properties: {}, required: [] }
},
required: []
}
},
required: [ 'id', 'name' ]
},
TodoUnion: {
oneOf: [
{ '$ref': '#/definitions/Todo' },
{ '$ref': '#/definitions/SimpleTodo' }
]
},
TodoInputType: {

@@ -286,0 +321,0 @@ type: 'object',

@@ -50,2 +50,11 @@ import {

"A simpler ToDo Object"
type SimpleTodo {
id: String!
name: String!
}
"A Union of Todo and SimpleTodo"
union TodoUnion = Todo | SimpleTodo
"""

@@ -370,2 +379,25 @@ A type that describes ToDoInputType. Its description might not

},
SimpleTodo: {
type: 'object',
description: 'A simpler ToDo Object',
properties: {
id: {
type: 'object',
properties: {
return: { $ref: '#/definitions/String' },
arguments: { type: 'object', properties: {}, required: [] },
},
required: [],
},
name: {
type: 'object',
properties: {
return: { $ref: '#/definitions/String' },
arguments: { type: 'object', properties: {}, required: [] },
},
required: [],
},
},
required: ['id', 'name'],
},
Color: {

@@ -398,2 +430,9 @@ // Yes, ENUM types should be the JSON built-in "string" type

},
TodoUnion: {
description: 'A Union of Todo and SimpleTodo',
oneOf: [
{ $ref: '#/definitions/Todo' },
{ $ref: '#/definitions/SimpleTodo' },
],
},
},

@@ -400,0 +439,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc