Skip to content

Commit 2e3be07

Browse files
authored
Update system configuration documentation to include TypeInfo (#9019)
1 parent c2a34c4 commit 2e3be07

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

docs/pages/docs/config/config.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ We will cover each of these options below.
3232
The configuration object has a TypeScript type of `KeystoneConfig`, which can be imported from `@keystone-6/core/types`.
3333
This type definition should be considered the source of truth for the available configuration options.
3434

35+
Note: It is important to pass a `TypeInfo` type argument to the config function as it ensures proper typing for the [Keystone Context](../context/overview.md). This type is automatically created in `.keystone/types`. You can customize the output path of the generated type by specifying it in the config object.
36+
37+
```typescript
38+
import { TypeInfo } from ".keystone/types";
39+
40+
export default config<TypeInfo>({ /* ... */ });
41+
```
42+
3543
## lists
3644

3745
The `lists` config option is where you define the data model, or schema, of the Keystone system.
@@ -42,8 +50,9 @@ See the [Lists API](./lists) docs for details on how to use this function.
4250
```typescript
4351
import type { ListSchemaConfig } from '@keystone-6/core/types';
4452
import { config } from '@keystone-6/core';
53+
import { TypeInfo } from ".keystone/types";
4554

46-
export default config({
55+
export default config<TypeInfo>({
4756
lists: { /* ... */ },
4857
/* ... */
4958
});
@@ -74,7 +83,7 @@ These database types are powered by their corresponding Prisma database provider
7483
### postgresql
7584

7685
```typescript
77-
export default config({
86+
export default config<TypeInfo>({
7887
db: {
7988
provider: 'postgresql',
8089
url: 'postgres://dbuser:dbpass@localhost:5432/keystone',
@@ -91,7 +100,7 @@ export default config({
91100
### mysql
92101

93102
```typescript
94-
export default config({
103+
export default config<TypeInfo>({
95104
db: {
96105
provider: 'mysql',
97106
url: 'mysql://dbuser:dbpass@localhost:3306/keystone',
@@ -107,7 +116,7 @@ export default config({
107116
### sqlite
108117

109118
```typescript
110-
export default config({
119+
export default config<TypeInfo>({
111120
db: {
112121
provider: 'sqlite',
113122
url: 'file:./keystone.db',
@@ -160,7 +169,7 @@ Advanced configuration:
160169
See the [Custom Admin UI Pages](../guides/custom-admin-ui-pages) guide for details on simpler ways to customise your Admin UI.
161170

162171
```typescript
163-
export default config({
172+
export default config<TypeInfo>({
164173
ui: {
165174
isDisabled: false,
166175
isAccessAllowed: async (context) => context.session !== undefined,
@@ -212,7 +221,7 @@ Options:
212221
- `extendHttpServer` (default: `undefined`): Allows you to extend the node `http` server that runs Keystone.
213222

214223
```typescript
215-
export default config({
224+
export default config<TypeInfo>({
216225
server: {
217226
cors: { origin: ['http://localhost:7777'], credentials: true },
218227
port: 3000,
@@ -236,7 +245,7 @@ The function is passed two arguments:
236245
For example, you could add your own request logging middleware:
237246

238247
```ts
239-
export default config({
248+
export default config<TypeInfo>({
240249
server: {
241250
extendExpressApp: (app) => {
242251
app.use((req, res, next) => {
@@ -251,7 +260,7 @@ export default config({
251260
Or add a custom route handler:
252261

253262
```ts
254-
export default config({
263+
export default config<TypeInfo>({
255264
server: {
256265
extendExpressApp: (app) => {
257266
app.get('/_version', (req, res) => {
@@ -265,7 +274,7 @@ export default config({
265274
You could also use it to add custom REST endpoints to your server, by creating a context for the request and using the Query API Keystone provides:
266275

267276
```ts
268-
export default config({
277+
export default config<TypeInfo>({
269278
server: {
270279
extendExpressApp: (app, commonContext) => {
271280
app.get('/api/users', async (req, res) => {
@@ -298,7 +307,7 @@ For example, this function could be used to listen for `'upgrade'` requests for
298307
import { WebSocketServer } from 'ws';
299308
import { useServer as wsUseServer } from 'graphql-ws/lib/use/ws';
300309

301-
export default config({
310+
export default config<TypeInfo>({
302311
server: {
303312
extendHttpServer: (httpServer, commonContext, graphqlSchema) => {
304313
const wss = new WebSocketServer({
@@ -329,7 +338,7 @@ In general you will use `SessionStrategy` objects from the `@keystone-6/core/ses
329338
```typescript
330339
import { statelessSessions } from '@keystone-6/core/session';
331340

332-
export default config({
341+
export default config<TypeInfo>({
333342
session: statelessSessions({ /* ... */ }),
334343
/* ... */
335344
});
@@ -359,7 +368,7 @@ Options:
359368
- `schemaPath` (default: `schema.graphql`): The path of the generated GraphQL API schema.
360369

361370
```typescript
362-
export default config({
371+
export default config<TypeInfo>({
363372
graphql: {
364373
debug: process.env.NODE_ENV !== 'production',
365374
path: '/api/graphql',
@@ -386,7 +395,7 @@ It has a TypeScript type of `ExtendGraphqlSchema`.
386395
```typescript
387396
import { config, graphql } from '@keystone-6/core';
388397

389-
export default config({
398+
export default config<TypeInfo>({
390399
extendGraphqlSchema: keystoneSchema => {
391400
/* ... */
392401
return newExtendedSchema
@@ -472,7 +481,7 @@ const {
472481
S3_SECRET_ACCESS_KEY: secretAccessKey = 'keystone',
473482
} = process.env;
474483

475-
export default config({
484+
export default config<TypeInfo>({
476485
/* ... */
477486
storage: {
478487
my_S3_images: {

0 commit comments

Comments
 (0)