I am tring to use fromGlobalId
from graphql-relay
:
import { nodeDefinitions, fromGlobalId } from 'graphql-relay';
import db from './database/index.js';
const idResolver = (globalId, context) => {
const { type, id } = fromGlobalId(globalId);
if (type === 'User') {
return db.getUser({ id }, context);
}
return null;
};
But I get this error in my console:
file:///Users/tomerlevi/Github/bali/graphql/node.js:5
import { fromGlobalId, nodeDefinitions } from 'graphql-relay';
^^^^^^^^^^^^
SyntaxError: The requested module 'graphql-relay' does not provide an export named 'fromGlobalId'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21)
at ModuleJob.run (internal/modules/esm/module_job.js:107:20)
at Loader.import (internal/modules/esm/loader.js:141:24)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! serverless-graphql@0.0.0 update-schema: `babel-node foundation/graphql/updateSchema.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serverless-graphql@0.0.0 update-schema script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I have looked into graphql-relay
and it clearly exports fromGlobalId
:
P.s: I am using node 13.6.0 in order to use es6 import syntax..
THANKS IN ADVANCE, ANY HELP WILL BE APPRECIATED.