Context
Context is a feature that allows you to pass custom data between the server and client.
This custom data is accessible in all your resolvers and most other callback functions on the server. For more information on using context on the server, see this guide
This guide shows how to "set" context for use on the server.
#
Setting contextThere are 3 client side APIs you can use to modify context data:
setContext#
setContext(data): Promise<Object>
data
(Object) Serializable data to be sent to the server. This data becomes accessible in all resolvers and most other callback functions on the server.
The setContext
API is used to set custom data that is sent to the server with every request.
note
This function overwrites any and all existing data. If you want to update/append data, use the updateContext
API instead.
updateContext#
updateContext(data): Promise<Object>
data
(Object) Serializable data to be sent to the server. This data is merged with any existing data. This data becomes accessible in all resolvers and most other callback functions on the server.
The updateContext
API is used to set custom data that is sent to the server with every request.
deleteContext#
deleteContext(): void
Deletes all data from context. Should be used when a user signs out.
#
ExampleFor an example on using context, see this guide