Skip to content

Commit

Permalink
docs(bootstrap): explain how to define resolvers array externally
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed Jun 8, 2020
1 parent 683963f commit 2ddfbe5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ const schema = await buildSchema({
});
```

In case of defining the resolvers array somewhere else (not inline in the `buildSchema`), we need to use the `as const` syntax to inform the TS compiler and satisfy the `NonEmptyArray<T>` constraints:

```typescript
// resolvers.ts
export const resolvers = [FirstResolver, SecondResolver] as const;

// schema.ts
import { resolvers } from "./resolvers";

const schema = await buildSchema({ resolvers });
```

However, when there are several resolver classes, manual imports can be cumbersome.
So we can also provide an array of paths to resolver module files instead, which can include globs:

Expand Down

0 comments on commit 2ddfbe5

Please sign in to comment.