Forward Client Extensions

Forward Client Extensions allow you to share arbitrary data between clients and subgraphs. For subscriptions, it is the only method for sharing init-session data.

Support for the "extensions" field in GraphQL Request JSON Payloads

For Query and Mutation

Cosmo Router supports sending the "extensions" field to Subgraphs. If a client sends an "extensions" field alongside a Query or Mutation, or alternatively as part of the "payload" of a Subscription Request, Cosmo Router will by default include the "extensions" field in all Subgraph requests.

This feature allows you to extend GraphQL in a very flexible way as defined by the GraphQL over HTTP specification.

Here's an example on how this can be used:


For initiating a subscription

Alternatively, this feature could be useful to send a token when initiating a subscription:

{"id":"1","type":"subscribe","payload":{"extensions":{"token":"asd"},"query":"subscription {\n  currentTime {\n    unixTime\n  }\n}"}}

More info on how this can be used with subscriptions can be found here.

Last updated