Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field "id" missing in typescript definition when using plugin #8

Open
litewarp opened this issue Apr 16, 2021 · 0 comments
Open

Field "id" missing in typescript definition when using plugin #8

litewarp opened this issue Apr 16, 2021 · 0 comments

Comments

@litewarp
Copy link

litewarp commented Apr 16, 2021

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), but is there any way to get nexus to realize the id does exist on the root type?

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
          },
        })
      },
    })
  },
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant