The first time a prisma enum is selected, Nexus would auto-project it into the schema.
Pros:
Very succinct write experience
Cons:
What if user has many prisma enums and doesn't want to project any of them? Then their autocomplete is filled with noise.
What if the schema is large with enums at both the prisma and api layers, keeping track of which layer they come from could become impossible? Matters?
Read experience seems pretty bad here. Very easy to miss what's going on.
Allow mapping enums like e.g. objects
User would get a new way to work with enums in Nexus
schema.extendType({
type: 'Mutation',
definition(t) {
t.boolean('upsertCalendar', {
args: {
// The following things are happening here:
// db is a static import
// db.Foo is a representation of the db layer enum called Foo
// db.Foo() projects the db layer Foo onto the api
// db.foo() returns a reference to the nexus graphql type
toto: schema.arg({ type: db.Foo() }),
},
resolve(_parent, args, ctx) {
// ...
},
})
},
})
The above achieves the succinctness of idea (1). But It can also capture the flexibility of idea (2):
Perceived Problem
Instances
Ideas / Proposed Solution(s)
Different ideas, no obvious winner yet
Select + automatically project
User would see all Prisma enums appear in
type
selection of an arg builder, like so:The first time a prisma enum is selected, Nexus would auto-project it into the schema.
Pros:
Cons:
Allow mapping enums like e.g. objects
User would get a new way to work with enums in Nexus
Then use it (looks just like above):
Pros:
alias
makes it possible to automate reverse aliasing when sending graphql args to prisma client. For example aboveC -> Z
thus:Cons:
A db projecting API
The above achieves the succinctness of idea (1). But It can also capture the flexibility of idea (2):
Could also easily be integrated into composites
pros:
mapBack
featurecons: