Docs

GraphQL EZ

Get Started

Configuration & Core Features#

GraphQL EZ allows deep configuration of everything and comes with some basic baked-in functionality

Some options depend on the integration, but the majority of the configuration applies to any application.

It's important to note that some more advanced configurations are not mentioned here, but you can always check the types of everything.

Schema#

You can specify a built schema (or a promise of a schema), for example, coming from TypeGraphQL or GraphQL Nexus, or you can use @graphql-ez/plugin-schema and make executable schemas that play well between other EZ Plugins.

// ... import { buildSchema } from 'type-graphql'; const schema = buildSchema({ // ... }); CreateApp({ //... schema, }); // ... import { makeSchema } from 'nexus'; const schema = makeSchema({ // ... }); CreateApp({ //... schema, });

Cache#

To have a good performance on a GraphQL API is always essential to leverage caching.

graphql-ez has built-in caching for parse and validation in the GraphQL API.

CreateApp({ // ... // Enable cache in 'parse' and 'validation' cache: true, }); CreateApp({ // ... // Enable cache in 'parse' but not in 'validation' cache: { parse: true, validation: false, }, }); CreateApp({ // ... // Enable cache in 'parse' and 'validation' with custom options cache: { // Default values parse: { max: 1000, ttl: 3600000, }, // Default values validation: { max: 1000, ttl: 3600000, }, }, });

Introspection#

For APIs that are not publicly open, it's always valuable to be able to disable the GraphQL Introspection

CreateApp({ //... introspection: { disable: process.env.NODE_ENV === 'production', }, });

Conditionally#

CreateApp({ //... introspection: { disable: { disableIf({ context }) { return context.req.headers.authorization !== 'SECRET'; }, }, }, });

Batched Queries#

You can enable (and also limit) Batched Queries in your API using allowBatchedQueries:

CreateApp({ //... allowBatchedQueries: true, }); CreateApp({ //... // Allow at most, five queries in a single request allowBatchedQueries: 5, });