useSchemaByContext
This plugin is the simplest plugin for specifying your GraphQL schema. You can specify a schema created from any tool that emits GraphQLSchema object, and you can choose to load the schema based on th
- Package
- @envelop/core
- Weekly downloads
- 5.5M
- Version
- 5.6.1
- License
- MIT
- Updated
- Sep 16, 2026
useSchemaByContext
This plugin is the simplest plugin for specifying your GraphQL schema. You can specify a schema
created from any tool that emits GraphQLSchema object, and you can choose to load the schema based
on the initial context (or the incoming request).
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine, useSchemaByContext } from '@envelop/core'
async function getSchema({ req }): GraphQLSchema {
if (req.isAdmin) {
return adminSchema
}
return userSchema
}
const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
useSchemaByContext(getSchema)
// ... other plugins ...
]
})