Define additional fields for prisma connection object #1281
-
The documentation includes a section demonstrating how to extend edges. However, is there a way to extend the connection object? For example: query {
users {
totalCount
totalActive # additional field
}
} I understand it's possible to create a connection object and assign that as the second argument of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There's no downside to creating the connection object yourself. Internally, it will just call 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,
}),
}),
},
) |
Beta Was this translation helpful? Give feedback.
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: