How could i manage to add or remove field from a GraphQL query #1877
-
Hi, I'm currently looking on how i could be able to add / remove fields from a query either be a directive (using KotlinSchemaDirectiveWiring). Is there an easy way i could adjust the fields a user is querying on an object, the fields are parts of the object definitions, it's only to figure out how i could add them to the query It would be use at some point to adjust some informations the client is requesting. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
No it is not possible. If a user requests You could use directives to apply some authentication mechanism to modify the response to return null for unauthenticated/unauthorized users but your response would still contain an entry for the given field. |
Beta Was this translation helpful? Give feedback.
No it is not possible. If a user requests
fieldA
then they are guaranteed to getfieldA
(or null if it is nullable) in the response OR its a server error. Changing request to remove some fields/add additional fields is breaking the contract (and will break your clients).You could use directives to apply some authentication mechanism to modify the response to return null for unauthenticated/unauthorized users but your response would still contain an entry for the given field.