Skip to content

Define additional fields for prisma connection object #1281

Answered by hayes
julioxavierr asked this question in Q&A
Discussion options

You must be logged in to vote

There's no downside to creating the connection object yourself. Internally, it will just call builder.connectionObject({...}) for you if you don't provide your own connection object.

You can also just define the fields inline in the connection options:

t.prismaConnection(
  {
    type: 'User',
    cursor: 'id',
    resolve: (query) => db.game.findMany({ ...query  }),
  },
  {
    fields: (t) => ({
      totalActive: t.int({
        resolve: () => 5,
      }),
    }),
  },
)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hayes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1280 on August 16, 2024 05:35.