When is it required to specify a resolver for `t.f...
# graphql-nexus
j
When is it required to specify a resolver for
t.field
. I sometimes have a parent fetching basically all properties for all the nested resolvers, but I dont wish to specify an explicit resolver bellow. If I were to do something like
Copy code
t.field('nestedField', { type: NestedFieldType, resolve: (parent => parent.nestedFieldType)})
, typescript complains that parent has no property nestedFIeld
r
Hey @Jonathan 👋 Would you be able to provide an example with a parent model?
j
Hey Ryan, I actually found out the source of "my problem" at the very least, which is that the backing type in the generated nexus uses the prisma's model (so in the generated file, I have)
Copy code
export interface NexusGenRootTypes {
  ParentType: prisma.parentType,
  etc..,
}
this is why I dont get nestedField as suggestion (but I do get
nestedFieldId
from prisma). I suppose I should somehow disable this functionality of nexus, and ensure that the generated types matches the objectType I defined rather than use Prisma as backing type, though I cant figure out how I enabled it intially (basically, to get the following)
Copy code
ParentType: {
  nestedField: etc
}
I could still offer up a mock of my resolvers, though I suspect turning off this auto-mapping to prisma-types will likely allow me to point my resolvers to "itself"
v
Hey @Jonathan, I'm in a similar situation. I have a field
User.fieldA
that's part of the User model, but I don't want to expose it through GraphQL so I don't add it as a field with nexus. However, a side effect of this is that Nexus has no clue that
fieldA
even exists. The issue here is that I do need to be able to retrieve this value, but it's not typed. There is some documentation on how you can add your own backing types here; https://nexusjs.org/docs/adoption-guides/nexus-framework-users#backing-types-type-discovery