-
I am trying to convert from nexus to pothos. Nexus has an objectType, but I do not know what is equivalent in Pothos Prisma Plugin Prisma Schema
In Nexus
Pothos schema
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
The closest direct comparison would be the simple-objects plugin, which was designed for exactly the pattern you are describing coming from nexus: https://pothos-graphql.dev/docs/plugins/simple-objects What I'd actually recommend though is using import { AnalyticsCashBalances } from '@prisma/client';
export const AnalyticsCashBalances = builder.objectRef<AnalyticsCashBalances>('AnalyticsCashBalances')
AnalyticsCashBalances.implement({
fields: (t) => ({
amount: t.exposeString('amount'),
balance: t.exposeString('balance'),
comment: t.exposeString('comment'),
createdAt: t.expose('createdAt', {
type: 'JSONScalar',
}),
customer: t.exposeString('customer'),
posName: t.exposeString('posName'),
shiftee: t.exposeString('shiftee'),
type: t.exposeString('type'),
}),
})
builder.prismaObject('analytics', {
fields: (t) => ({
id: t.exposeID('id'),
firebaseId: t.exposeString('firebaseId'),
userId: t.exposeString('userId'),
sourceData: t.exposeString('sourceData'),
cashBalances: t.expose('cashBalances', {
type: AnalyticsCashBalances
} ),
}),
}) |
Beta Was this translation helpful? Give feedback.
-
Thank you! @hayes, I tried your solution but got an error.
When importing AnalyticsCashBalances. Do you have any idea why? |
Beta Was this translation helpful? Give feedback.
The closest direct comparison would be the simple-objects plugin, which was designed for exactly the pattern you are describing coming from nexus: https://pothos-graphql.dev/docs/plugins/simple-objects
What I'd actually recommend though is using
builder.objectRef
: https://pothos-graphql.dev/docs/guide/objects#using-refs