Skip to content

Commit

Permalink
Move createImagesContext inside makeCreateContext (#5522)
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie committed Apr 23, 2021
1 parent 4130ce2 commit fbf5f77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-avocados-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystone-next/keystone': patch
---

Moved the call to `createImagesContext` into `makeCreateContext()`.
8 changes: 5 additions & 3 deletions packages-next/keystone/src/lib/createContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ import type {
KeystoneContext,
KeystoneGraphQLAPI,
BaseKeystone,
ImagesContext,
ImagesConfig,
} from '@keystone-next/types';

import { itemDbAPIForList, itemAPIForList, getArgsFactory } from './itemAPI';
import { accessControlContext, skipAccessControlContext } from './createAccessControlContext';
import { createImagesContext } from './createImagesContext';

export function makeCreateContext({
graphQLSchema,
internalSchema,
keystone,
images,
imagesConfig,
}: {
graphQLSchema: GraphQLSchema;
internalSchema: GraphQLSchema;
keystone: BaseKeystone;
images: ImagesContext | undefined;
imagesConfig?: ImagesConfig;
}) {
const images = createImagesContext(imagesConfig);
// We precompute these helpers here rather than every time createContext is called
// because they require parsing the entire schema, which is potentially expensive.
const publicGetArgsByList: Record<string, ReturnType<typeof getArgsFactory>> = {};
Expand Down
3 changes: 1 addition & 2 deletions packages-next/keystone/src/lib/createSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { KeystoneConfig } from '@keystone-next/types';
import { createGraphQLSchema } from './createGraphQLSchema';
import { makeCreateContext } from './createContext';
import { createKeystone } from './createKeystone';
import { createImagesContext } from './createImagesContext';

export function createSystem(config: KeystoneConfig, prismaClient?: any) {
const keystone = createKeystone(config, prismaClient);
Expand All @@ -16,7 +15,7 @@ export function createSystem(config: KeystoneConfig, prismaClient?: any) {
keystone,
graphQLSchema,
internalSchema,
images: createImagesContext(config.images),
imagesConfig: config.images,
});

return { keystone, graphQLSchema, createContext };
Expand Down

1 comment on commit fbf5f77

@vercel
Copy link

@vercel vercel bot commented on fbf5f77 Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.