I see that by default, all fields that you define ...
# graphql-nexus
p
I see that by default, all fields that you define in your Nexus object model are exposed. Is there anyway to not have all models exposed? I’m using the t.model to combine multiple fields in my Prisma model to output it as one field in graphql
Copy code
const customer = objectType({
  name: “customer”,
  definition(t) {
    t.model.addressLine1
    t.model.addressLine2
    t.field(“address”, {
      type: “string”,
      resolve: (root) => root.addressLine1 + root.addressLine2
    }
  }
});
and I don’t want the graphql to have “addressLine1” and “addressLine2” because it’s unnecessary.
👍 1
b
You shouldn’t need either of those lines,
root.addressLine1/2
are both always available regardless of what your object definition declares.
p
When I don’t include
t.model.addressLine1()
I get a typescript error in
Copy code
t.field("address", {
      type: "string",
      resolve: (root) => root.addressLine1 + root.addressLine2
    }
saying addressLine1 doesn’t exist
l
It might help to use the rootTyping option on objectType in order to apply a backing type for typescript