Skip to content

Commit

Permalink
Update graphql/graphql-relay and add support for Sequelize 6 (#715)
Browse files Browse the repository at this point in the history
  • Loading branch information
intellix authored Nov 16, 2022
1 parent b70b052 commit e833cf9
Show file tree
Hide file tree
Showing 10 changed files with 2,872 additions and 2,117 deletions.
3,162 changes: 1,843 additions & 1,319 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"lodash": "^4.0.0"
},
"peerDependencies": {
"graphql": "^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14",
"graphql-relay": "^0.4.2 || ^0.5.0 || ^0.6.0",
"graphql": "^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14 || ^15 || ^16",
"graphql-relay": "^0.4.2 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0",
"sequelize": ">=3.0.0"
},
"devDependencies": {
Expand All @@ -60,18 +60,18 @@
"chai": "^3.0.0",
"chai-as-promised": "^5.1.0",
"eslint": "^1.7.3",
"graphql": "^0.13.0",
"graphql-relay": "^0.6.0",
"graphql": "^16.6.0",
"graphql-relay": "^0.10.0",
"isparta": "^4.0.0",
"istanbul": "^0.4.0",
"mocha": "^3.0.1",
"mysql": "^2.11.1",
"pg": "^5.0.0",
"pg-hstore": "^2.3.2",
"sequelize": "^3.24.6",
"sequelize": "^6.25.6",
"sinon": "^1.15.4",
"sinon-as-promised": "^4.0.0",
"sinon-chai": "^2.8.0",
"sqlite3": "^4.0.0"
"sqlite3": "^5.1.2"
}
}
6 changes: 4 additions & 2 deletions src/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function idFetcher(sequelize, nodeTypeMapper) {

const model = Object.keys(sequelize.models).find(model => model === type);
if (model) {
return sequelize.models[model].findById(id);
return sequelize.models[model].findByPk ? sequelize.models[model].findByPk(id) : sequelize.models[model].findById(id);
}

if (nodeType) {
Expand All @@ -75,6 +75,8 @@ export function typeResolver(nodeTypeMapper) {
? obj.Model.options.name.singular
: obj._modelOptions
? obj._modelOptions.name.singular
: obj.constructor.options
? obj.constructor.options.name.singular
: obj.name);

if (!type) {
Expand All @@ -84,7 +86,7 @@ export function typeResolver(nodeTypeMapper) {

const nodeType = nodeTypeMapper.item(type);
if (nodeType) {
return typeof nodeType.type === 'string' ? info.schema.getType(nodeType.type) : nodeType.type;
return typeof nodeType.type === 'string' ? nodeType.type : nodeType.type.name;
}

return null;
Expand Down
1 change: 0 additions & 1 deletion src/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import _ from 'lodash';
import argsToFindOptions from './argsToFindOptions';
import { isConnection, handleConnection, nodeType } from './relay';
import assert from 'assert';
import Promise from 'bluebird';

function whereQueryVarsToValues(o, vals) {
[
Expand Down
Loading

0 comments on commit e833cf9

Please sign in to comment.