reactjs - Error: UserCreatePayload.viewer field type must be Output Type but got: undefined -
the code below works when entire schema in single file, i'm getting above error when try split individual files.
i'm importing types , functions.
i have add more details, i'm not sure say. think it's sequencing problem since works in single file, not split up.
thanks lot.
const usercreatemutation = mutationwithclientmutationid({ name: 'usercreate', inputfields: { email: {type: new graphqlnonnull(graphqlstring)}, password: {type: new graphqlnonnull(graphqlstring)} }, outputfields: { viewer: { type: viewertype, resolve() { return viewerget(); } }, field: { type: usertype, resolve(node) { return node; } } }, async mutateandgetpayload({email, password}, {db, req}) { export const viewertype = new graphqlobjecttype({ name: 'viewer', fields() { return { id: globalidfield('viewer', ({_id: viewerlocalid}) => { return viewerlocalid; }), _id: {type: graphqlid}, user: { type: usertype, resolve(parent, args, {req: {user}}) { return user || {}; } }, profile: { type: profileconnectiontype, args: { id: {type: graphqlid}, searchterm: {type: graphqlstring}, ...connectionargs }, resolve(parent, {id: profileglobalid, searchterm, ...connectionargs}, {db}) { const query = (() => { const q = {}; if (profileglobalid) { const {id: profilelocalid} = fromglobalid(profileglobalid); object.assign( q, {_id: new objectid(profilelocalid)} ); } if (searchterm) { object.assign( q, { $text: { $search: `\"${searchterm}\"` } } ); } return q; })(); const sort = {_id: -1}; const limit = 0; return connectionfrompromisedarray( promisedarrayget( query, sort, limit, profilecollectionname, db ), connectionargs ); } } }; }, interfaces: [nodeinterface] }); class viewer extends object {} export const viewerget = () => { return object.assign( new viewer(), { _id: 'viewer' } ); }; import { viewertype, usertype, viewerget }
not sure if problem module-loading order issue. if problem, can solve making outputfields thunk, i.e. function returns object instead of plain object.
outputfields: () => ({ viewer: { type: viewertype, resolve() { return viewerget(); } }, field: { type: usertype, resolve(node) { return node; } } }),
Comments
Post a Comment