You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PothosSchemaError [GraphQLError]: Node has not been implemented
...and a kinda ugly, really deep typescript type mismatch error
i discovered that the relay plugin exports NodeRef, so I tried
import{builder,localID}from'#lib';importtype{SchemaTypes}from'@pothos/core';import{NodeRef}from'@pothos/plugin-relay';import{LocalID}from'../types/local-id.js';builder.interfaceField(NodeRef<SchemaTypes,{id: string}>,'localID',(t)=>t.field({type: LocalID,resolve: ({ id })=>localID(id),description: "L'identifiant local de la ressource (sans préfixe)",}),);
(localID is a simple (id: string) => string function, builder is a Pothos builder)
but I get another error, with a seemingly similar root cause:
[@churros/api]: PothosSchemaError [GraphQLError]: Missing implementations for some references (class NodeRef extends ObjectRef {
[@churros/api]: constructor(name, options) {
[@churros/api]: super(name);
[@churros/api]: _define_property(this, _relayIDShapeKey, void 0);
[@churros/api]: _define_property(this, "parseId", void 0);
[@churros/api]: this.parseId = options.parseId;
[@churros/api]: }
[@churros/api]: }).
[@churros/api]: at constructor (/home/uwun/projects.local/churros/node_modules/@pothos/core/src/errors.ts:7:5)
[@churros/api]: at constructor (/home/uwun/projects.local/churros/node_modules/@pothos/core/src/errors.ts:14:5)
[@churros/api]: at ConfigStore.prepareForBuild (/home/uwun/projects.local/churros/node_modules/@pothos/core/src/config-store.ts:339:5)
[@churros/api]: at BuildCache.buildAll (/home/uwun/projects.local/churros/node_modules/@pothos/core/src/build-cache.ts:166:22)
[@churros/api]: at SchemaBuilder.toSchema (/home/uwun/projects.local/churros/node_modules/@pothos/core/src/builder.ts:668:11)
[@churros/api]: at <anonymous> (/home/uwun/projects.local/churros/packages/api/src/schema.ts:35:61) {
[@churros/api]: path: undefined,
[@churros/api]: locations: undefined,
[@churros/api]: extensions: [Object: null prototype] {}
[@churros/api]: }
Note that the API works really well without that .interfaceField call, so Node seems to be implemented correctly, it just seems like it's implemented after that builder.interfaceField call?
I'm certain the file making that call is imported after the builder is called, so I'd expect Node to be implemented at that point.
Is there a way to add fields on the Node interface?
The text was updated successfully, but these errors were encountered:
ewen-lbh
changed the title
Adding fields to @pothos/prisma-relay's Node interface
Adding fields to @pothos/plugin-relay's Node interface
Jul 22, 2024
I think this was somewhat coincidental that this worked before, but the correct way to handle this is pretty straight forward. You can use builder.nodeInterfaceRef() to get a ref that can be passed to builder.interfaceField: https://stackblitz.com/edit/typescript-v6gz5m?file=index.ts
Thanks! I created a PR to mention this in the docs (if it's not already there... i'm always scared of asking something because i missed it in the docs, even after looking through it a thousand times lol)
is adding additional fields on the Node interface supported? i didn't see anything mentionned in the docs.
it worked nicely before v4 using
builder.interfaceField(...)
(for example: https://github.com/inp-net/churros/blob/22cf7d1eff32d904d34de336fe9bb844c3a5ea6e/packages/api/src/modules/global/resolvers/node.local-id.ts)but i'm now getting a GraphQLError:
...and a kinda ugly, really deep typescript type mismatch error
i discovered that the relay plugin exports
NodeRef
, so I tried(
localID
is a simple(id: string) => string
function,builder
is a Pothos builder)but I get another error, with a seemingly similar root cause:
Note that the API works really well without that
.interfaceField
call, soNode
seems to be implemented correctly, it just seems like it's implemented after that builder.interfaceField call?I'm certain the file making that call is imported after the builder is called, so I'd expect
Node
to be implemented at that point.Is there a way to add fields on the
Node
interface?The text was updated successfully, but these errors were encountered: