Skip to content

Latest commit

 

History

History
31 lines (17 loc) · 914 Bytes

Hiding fields in REST responses.md

File metadata and controls

31 lines (17 loc) · 914 Bytes

Hiding fields in REST responses

A common use case is where a GraphQL API is used internally, then GraphQL2REST is used to expose a public REST API based on it. In this case we may want to hide certain fields in the GraphQL response from users of the external REST API.

To hide fields, use the hide property in the endpoints section of the manifest file. hide is an array of fields to filter out of the response. For nested fields, use dot notation ("parent.child1.child2").

Example:

"/users/:id/configurations": {
	"get": {
		"operation": "getUserConfig",
		"hide": ["internalId", "secrets.creditCardNum"]
	}
}

Next: read about mapping to GraphQL operations using conditional logic or jump to the pre-processing step.



[Back to the tutorial]