GraphQL

Write an awesome doc for GraphQL. A very nice an practical one extracted from GraphQL official documentation.

View on GitHub

Query Depth

@escape.tech/graphql-armor

[!NOTE]

At first I thought to use graphql-depth-limit-ts, but then I found @escape.tech/graphql-armor. It offers features provided by graphql-query-complexity and graphql-depth-limit-ts. So I am down :joy:.

I am gonna try this lib with type-graphql. The e2e tests + app: apps/depth and apps/depth-e2e.

  1. pnpm install graphql type-graphql reflect-metadata typeorm pg @escape.tech/graphql-armor
    
  2. nx g @nx/node:app apps/depth --framework express --bundler esbuild
    
  3. Configure your TypeORM and type-graphql backend.
  4. Configure your @escape.tech/graphql-armor with your Apollo Server (learn more).

For example this query with that config will work:

GraphQL Query Config
```graphql query { businesses { edges { cursor node { id name customers { id shopAt { id customers { id } } } } } } } ``` ```ts new ApolloArmor({ maxDepth: { enabled: true, ignoreIntrospection: true, n: 7, flattenFragments: true, }, costLimit: { enabled: true, depthCostFactor: 1.5, objectCost: 2, scalarCost: 1, ignoreIntrospection: true, flattenFragments: true, maxCost: 100, }, }); ```