Skip to content

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

@litewarp

Description

@litewarp

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
          },
        })
      },
    })
  },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions