🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

graphql-compose-json

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-compose-json - npm Package Compare versions

Comparing version

to
4.1.0

60

lib/__tests__/composeWithJson-test.js

@@ -208,2 +208,62 @@ "use strict";

});
it('check array of swallow objects', async () => {
const restApiResponse = {
name: 'Luke Skywalker',
limbs: [{
kind: 'arm',
position: 'left',
length: 76
}, {
kind: 'arm',
position: 'left',
length: 76
}, {
kind: 'leg',
position: 'left',
length: 81
}, {
kind: 'leg',
position: 'right',
length: 82
}]
};
const PersonTC = (0, _index.composeWithJson)('PersonCustom', restApiResponse);
const schema1 = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
person: {
type: PersonTC.getType(),
resolve: () => {
return restApiResponse;
}
}
}
})
});
const res = await _graphqlCompose.graphql.graphql(schema1, `{
person {
name
limbs {
length
}
}
}`);
expect(res).toEqual({
data: {
person: {
name: 'Luke Skywalker',
limbs: [{
length: 76
}, {
length: 76
}, {
length: 81
}, {
length: 82
}]
}
}
});
});
});

@@ -39,2 +39,17 @@ "use strict";

});
it('of object', () => {
const spy = jest.spyOn(_ObjectParser.default, 'createTC');
const valueAsArrayOfObjects = [{
a: 123
}, {
a: 456
}];
_ObjectParser.default.getFieldConfig(valueAsArrayOfObjects, {
typeName: 'ParentTypeName',
fieldName: 'subDocument'
});
expect(spy).toHaveBeenCalledWith('ParentTypeName_SubDocument', valueAsArrayOfObjects[0]);
});
it('of any', () => {

@@ -41,0 +56,0 @@ expect(_ObjectParser.default.getFieldConfig([null])).toEqual(['JSON']);

6

lib/ObjectParser.js

@@ -40,3 +40,7 @@ "use strict";

if (Array.isArray(val)) return ['JSON'];
return [this.getFieldConfig(val)];
const args = opts && opts.typeName && opts.fieldName ? {
typeName: opts.typeName,
fieldName: opts.fieldName
} : {};
return [this.getFieldConfig(val, args)];
}

@@ -43,0 +47,0 @@

5

package.json
{
"name": "graphql-compose-json",
"version": "4.0.1",
"version": "4.1.0",
"description": "This is a plugin for `graphql-compose`, which generates GraphQLTypes from any JSON.",

@@ -40,2 +40,3 @@ "files": [

"babel-jest": "^24.8.0",
"cross-env": "^5.2.0",
"eslint": "^5.16.0",

@@ -68,3 +69,3 @@ "eslint-config-airbnb-base": "^13.1.0",

"flow": "./node_modules/.bin/flow",
"test": "npm run coverage && npm run lint && npm run flow",
"test": "cross-env NODE_ENV=test npm run coverage && npm run lint && npm run flow",
"semantic-release": "semantic-release",

@@ -71,0 +72,0 @@ "fixture-demo": "./node_modules/.bin/babel-node ./src/__fixtures__/app.js"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet