Skip to main content
Version: 2.x

GraphQL context

Front-Commerce’s GraphQL modules can register GraphQL schema extensions and resolvers to actually fetch the data. This page contains the different keys available in the GraphQL context object managed by Front-Commerce.

Front-Commerce manages a context object and makes it available in the GraphQL schema so resolvers can use it using standard GraphQL mechanisms.


To get started with GraphQL modules, we recommend you to read the Extend the GraphQL schema documentation page.


The loaders key contains all the loaders registered by GraphQL modules, from their contextEnhancer module definition method.

Example :

export default {
Product: {
clicksCounter: ({ sku }, _, context) => {
return context.loaders.Counter.loadBySku(sku);

See Slim down resolvers with loaders to understand how to leverage this value.


The req key contains the current HTTP request (from Express server) having triggered the GraphQL query.

It could be useful in some specific cases, but we generally recommend NOT TO use it directly. Resolvers should to use loaders instead.

One of the reason why it has been introduced in the core, is to allow context customization in Remote schema stitching scenario. See linkContextBuilders for an usage example.