JCMais / JCMais/nexus-plugins

Field "id" missing in typescript definition when using plugin

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
24
Forks
1
PR merge metrics
No merged PRs in 30d

Description

When I use the plugin and define id as a relayGlobalId field, it results in a type error stating that "id" is not found on the object. If I use the model ID instead of relay (uncomment line below), there is no type error, but the id is obviously not relay-compliant. I'm not sure if this is related to graphql-nexus/nexus#36 (see [comment](https://github.com/graphql-nexus/nexus/issues/36#issuecomment-780829713)), but is there any way to get nexus to realize the id does exist on the root type?

```JSX
const Task = objectType({
name: TaskModel.$name,
definition: (t) => {
t.implements('Node')
t.relayGlobalId('id', {})
// t.field(TaskModel.id.name, TaskModel.id)
t.connectionField('comments', {
type: 'Comment',
resolve: async (src, args, ctx, info) => {
const comments = db.comment.find({
where: {
taskId: src.id, // <==== TypeError Here
},
})
},
})
},
})
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.