Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Sep 3, 2021
1 parent 0b9a2d3 commit a0693fd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/pages/docs/apis/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Options:
- `queryLimits` (default: `undefined`): Allows you to limit the total number of results returned from a query to your GraphQL API.
See also the per-list `graphql.queryLimits` option in the [Schema API](./schema).
- `path` (default: `'/api/graphql'`): The path of the GraphQL API endpoint.
- `cors` : FIXME
- `cors` (default: `rocess.env.NODE_ENV !== 'production' ? { origin: 'https://studio.apollographql.com', credentials: true } : undefined`): The CORS configuration to use on the GraphQL API endpoint. The default is setup to allow access access to API from the Apollo Sandbox during development
- `apolloConfig` (default: `undefined`): Allows you to pass [extra options](https://www.apollographql.com/docs/apollo-server/api/apollo-server/#constructor) into the `ApolloServer` constructor.

```typescript
Expand Down
6 changes: 5 additions & 1 deletion packages/keystone/src/lib/server/createExpressServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ const addApolloServer = async ({
apolloServer.applyMiddleware({
app: server,
path: config.graphql?.path || '/api/graphql',
cors: config.graphql?.cors || { origin: 'https://studio.apollographql.com', credentials: true },
cors:
config.graphql?.cors ||
(process.env.NODE_ENV !== 'production'
? { origin: 'https://studio.apollographql.com', credentials: true }
: undefined),
});
};

Expand Down
2 changes: 2 additions & 0 deletions packages/keystone/src/types/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export type ServerConfig = {
export type GraphQLConfig = {
// The path of the GraphQL API endpoint. Default: '/api/graphql'.
path?: string;
// The CORS configuration to use on the GraphQL API endpoint.
// Default: { origin: 'https://studio.apollographql.com', credentials: true }
cors?: CorsOptions;
queryLimits?: {
maxTotalResults?: number;
Expand Down

0 comments on commit a0693fd

Please sign in to comment.