From c1f1850b8bb207094a01eb0ef1bf484efd932d06 Mon Sep 17 00:00:00 2001 From: nodkz Date: Tue, 25 Oct 2016 23:51:51 +0600 Subject: [PATCH] fix(Dependencies): Fixes due deprecated methods in `graphql-compose` --- package.json | 4 ++-- src/__tests__/composeWithMongoose-test.js | 8 ++++---- src/composeWithMongoose.js | 2 +- src/resolvers/helpers/filter.js | 8 ++++---- src/resolvers/helpers/record.js | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 0922a395..50ca77d9 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ }, "peerDependencies": { "graphql": ">=0.7.1 || >=0.8.0", - "graphql-compose": ">=1.0.0", - "graphql-compose-connection": ">=2.0.0", + "graphql-compose": ">=1.4.0", + "graphql-compose-connection": ">=2.0.2", "mongoose": ">=4.0.0" }, "devDependencies": { diff --git a/src/__tests__/composeWithMongoose-test.js b/src/__tests__/composeWithMongoose-test.js index acbf32ad..6bad74dc 100644 --- a/src/__tests__/composeWithMongoose-test.js +++ b/src/__tests__/composeWithMongoose-test.js @@ -120,9 +120,9 @@ describe('composeWithMongoose ->', () => { }, }).getInputTypeComposer(); - expect(inputTypeComposer.isFieldRequired('name')).to.be.true; - expect(inputTypeComposer.isFieldRequired('gender')).to.be.true; - expect(inputTypeComposer.isFieldRequired('age')).to.be.false; + expect(inputTypeComposer.isRequired('name')).to.be.true; + expect(inputTypeComposer.isRequired('gender')).to.be.true; + expect(inputTypeComposer.isRequired('age')).to.be.false; }); }); @@ -167,7 +167,7 @@ describe('composeWithMongoose ->', () => { }); const filterArgInFindOne = typeComposer.getResolver('findOne').getArg('filter'); const inputConposer = new InputTypeComposer(filterArgInFindOne.type); - expect(inputConposer.isFieldRequired('age')).to.be.true; + expect(inputConposer.isRequired('age')).to.be.true; }); }); }); diff --git a/src/composeWithMongoose.js b/src/composeWithMongoose.js index 2f38fe04..e74d6856 100644 --- a/src/composeWithMongoose.js +++ b/src/composeWithMongoose.js @@ -84,7 +84,7 @@ export function prepareInputFields( inputTypeComposer.removeField(inputFieldsOpts.remove); } if (inputFieldsOpts.required) { - inputTypeComposer.makeFieldsRequired(inputFieldsOpts.required); + inputTypeComposer.makeRequired(inputFieldsOpts.required); } } diff --git a/src/resolvers/helpers/filter.js b/src/resolvers/helpers/filter.js index ae7604a8..568e566b 100644 --- a/src/resolvers/helpers/filter.js +++ b/src/resolvers/helpers/filter.js @@ -66,10 +66,10 @@ export const filterHelperArgs = ( inputComposer.removeField(removeFields); if (opts.requiredFields) { - inputComposer.makeFieldsRequired(opts.requiredFields); + inputComposer.makeRequired(opts.requiredFields); } - if (!opts.hasOwnProperty('operators') || opts.operators !== false) { + if (!{}.hasOwnProperty.call(opts, 'operators') || opts.operators !== false) { addFieldsWithOperator( // $FlowFixMe `Operators${opts.filterTypeName}`, @@ -208,7 +208,7 @@ export function addFieldsWithOperator( }); if (Object.keys(fields).length > 0) { const operatorTypeName = `${upperFirst(fieldName)}${typeName}`; - operatorsComposer.addField(fieldName, { + operatorsComposer.setField(fieldName, { type: typeStorage.getOrSet( operatorTypeName, new GraphQLInputObjectType({ @@ -223,7 +223,7 @@ export function addFieldsWithOperator( }); if (Object.keys(operatorsComposer.getFields()).length > 0) { - inputComposer.addField(OPERATORS_FIELDNAME, { + inputComposer.setField(OPERATORS_FIELDNAME, { type: operatorsComposer.getType(), description: 'List of fields that can be filtered via operators', }); diff --git a/src/resolvers/helpers/record.js b/src/resolvers/helpers/record.js index b8cf9b25..fb1dd08e 100644 --- a/src/resolvers/helpers/record.js +++ b/src/resolvers/helpers/record.js @@ -34,7 +34,7 @@ export const recordHelperArgs = ( } if (opts && opts.requiredFields) { - recordComposer.makeFieldsRequired(opts.requiredFields); + recordComposer.makeRequired(opts.requiredFields); } return {