1

For example, let's say I have this Query and Type in my code and I don't want it to show _id in Apollo sandbox explorer. Please is there a way to achieve this?

type Query {
    getUser(userId: String!): UserObject
}

type UserObject {
    _id: String
    email: String
    firstName: String
}

I'm trying to make it show only email and firstName without the _id field in apollo sandbox explorer.

I've tried using introspection but it didn't show all my queries and mutations as expected. I've tried using directives but I'm not getting it and I don't know how. It should show something like this in the explorer, without the _id field.

type Query {
    getUser(userId: String!): UserObject
}

type UserObject {
    email: String
    firstName: String
}
ThisaruG
  • 3,222
  • 7
  • 38
  • 60
Erin Deji
  • 92
  • 6
  • What are you trying to achieve here? The GraphQL sandbox is generating the schema using an introspection query and it shows everything your schema has. I can't think of a reason to hide it only in the sandbox. If you want to remove that field completely, you can use a directive. Even in this case, the `_id` field will be removed from the schema not just from the sandbox. – ThisaruG Apr 11 '23 at 04:53
  • It's a secret field used only in the code. For example, I need the secret field in my unit test and I don't want that field to be available for client apps to use. – Erin Deji Apr 11 '23 at 10:48

0 Answers0