graphql-compose-json
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -1,2 +0,2 @@ | ||
import { ObjectTypeComposer, ObjectTypeComposerFieldConfigDefinition } from 'graphql-compose'; | ||
import { ObjectTypeComposer, ObjectTypeComposerFieldConfigDefinition, SchemaComposer } from 'graphql-compose'; | ||
declare type GetValueOpts = { | ||
@@ -7,3 +7,5 @@ typeName?: string; | ||
export default class ObjectParser { | ||
static createTC(name: string, json: Record<string, any>): ObjectTypeComposer<any, any>; | ||
static createTC(name: string, json: Record<string, any>, opts?: { | ||
schemaComposer: SchemaComposer<any>; | ||
}): ObjectTypeComposer<any, any>; | ||
static getFieldConfig(value: any, opts?: GetValueOpts | null): ObjectTypeComposerFieldConfigDefinition<any, any>; | ||
@@ -10,0 +12,0 @@ } |
@@ -14,3 +14,3 @@ "use strict"; | ||
} | ||
ObjectParser.createTC = function (name, json) { | ||
ObjectParser.createTC = function (name, json, opts) { | ||
var _this = this; | ||
@@ -20,3 +20,4 @@ if (!json || typeof json !== 'object') { | ||
} | ||
var tc = graphql_compose_1.ObjectTypeComposer.createTemp(name); | ||
var sc = (opts === null || opts === void 0 ? void 0 : opts.schemaComposer) || graphql_compose_1.schemaComposer; | ||
var tc = sc.createObjectTC(name); | ||
Object.keys(json).forEach(function (fieldName) { | ||
@@ -23,0 +24,0 @@ var fieldConfig = _this.getFieldConfig(json[fieldName], { typeName: name, fieldName: fieldName }); |
{ | ||
"name": "graphql-compose-json", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "This is a plugin for `graphql-compose`, which generates GraphQLTypes from any JSON.", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -139,4 +139,7 @@ # graphql-compose-json | ||
```js | ||
import { schemaComposer } from 'graphql-compose'; | ||
import { SchemaComposer } from 'graphql-compose'; | ||
const schemaComposer = new SchemaComposer(); | ||
const PersonTC = composeWithJson('CustomPerson', restApiResponse, { schemaComposer }); | ||
schemaComposer.Query.addFields({ | ||
@@ -143,0 +146,0 @@ person: { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22892
253
260
0