Accessing @inContext directive when stitching schemas

Accessing @inContext directive when stitching schemas

2 0 0

I'm having a little trouble accessing the `inContext` directive after stitching the Shopify shopfront API schema with my local schema. 

const {makeExecutableSchema} = require('@graphql-tools/schema')
const {stitchSchemas} = require('@graphql-tools/stitch')
const {buildHTTPExecutor} = require('@graphql-tools/executor-http')
const {schemaFromExecutor, RenameTypes, RenameRootFields} = require('@graphql-tools/wrap')
const env = require('./../env')

const typeDefs = require('./types')
const resolvers = require('./resolvers')

const boilerRoomSchema = makeExecutableSchema({
  logger: console,

const shopifyRemoteExecutor = buildHTTPExecutor({
  endpoint: '',
  headers: {
    'X-Shopify-Storefront-Access-Token': env.SHOPIFY_ACCESS_TOKEN,

const createShopifySchema = async () => ({
  schema: await schemaFromExecutor(shopifyRemoteExecutor),
  executor: shopifyRemoteExecutor,
  transforms: [
    new RenameTypes(name => `shopify_${name}`),
    new RenameRootFields((operationName, fieldName, fieldConfig) => `shopify_${fieldName}`),

const createSchema = async () => {
  const shopifySchema = await createShopifySchema()

  return stitchSchemas({
    subschemas: [

module.exports = createSchema
Replies 2 (2)

Shopify Staff
2873 312 819


Hi BoilerRoom,


Directives are not included by default when fetching a remote schema because the introspection query used to fetch the schema doesn't include them. You might need to manually add the inContext directive to your local schema.


Here is an example of can define it in your local schema:

directive @inContext(
  country: String
) on FIELD

type Query {
  products: [Product] @inContext(country "CA")
  // ... other fields

// ... other types

Try this out and let us know if you're still seeing issues!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog

2 0 0

By adding `mergeDirectives: true` to `stitchSchemas` we can see the `inContext` directive when querying for directives, however it doesn't seem to be being passed to the Shopify stitched schema queries.