Skip to content

Commit

Permalink
Merge branch 'master' into update-copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Mar 9, 2021
2 parents 4fae82e + 1d23ce5 commit fa242ff
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 331 deletions.
5 changes: 0 additions & 5 deletions .changeset/chilled-items-call.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/cyan-buckets-happen.md

This file was deleted.

6 changes: 6 additions & 0 deletions .changeset/large-cobras-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@keystone-next/admin-ui': major
'@keystone-next/keystone': major
---

Updated `createApolloServerMicro` to take system arguments rather than a `KeystoneConfig` object.
5 changes: 0 additions & 5 deletions .changeset/lovely-socks-confess.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/weak-swans-count.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/wise-papayas-crash.md

This file was deleted.

8 changes: 8 additions & 0 deletions docs-next/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @keystone-next/website

## 1.1.1

### Patch Changes

- [#5073](https://github.com/keystonejs/keystone/pull/5073) [`ba637676b`](https://github.com/keystonejs/keystone/commit/ba637676b83625b06581daae6fd625d8fb0b612d) Thanks [@gwyneplaine](https://github.com/gwyneplaine)! - Moved viewport meta tag from \_document to \_app to avoid dedupe issues and next warnings.

* [#5072](https://github.com/keystonejs/keystone/pull/5072) [`5a78af92e`](https://github.com/keystonejs/keystone/commit/5a78af92e1ab364f9ab444c5244f9581e33bad1f) Thanks [@timleslie](https://github.com/timleslie)! - Updated cypress tests to pre-build the site before running the tests.

## 1.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion docs-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keystone-next/website",
"version": "1.1.0",
"version": "1.1.1",
"private": true,
"license": "MIT",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions packages-next/admin-ui/src/templates/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
export const apiTemplate = `
import keystoneConfig from '../../../../keystone';
import { createApolloServerMicro } from '@keystone-next/keystone';
import { initConfig, createSystem, createApolloServerMicro } from '@keystone-next/keystone';
const apolloServer = createApolloServerMicro(keystoneConfig);
const config = initConfig(keystoneConfig);
const { graphQLSchema, keystone, createContext } = createSystem(config, '.keystone', 'start');
const apolloServer = createApolloServerMicro({
graphQLSchema,
createContext,
sessionStrategy: _config.session ? _config.session() : undefined,
connectionPromise: keystone.connect(),
});
export const config = {
api: {
Expand Down
11 changes: 11 additions & 0 deletions packages-next/keystone/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @keystone-next/keystone

## 11.0.2

### Patch Changes

- [#5079](https://github.com/keystonejs/keystone/pull/5079) [`57c98c90e`](https://github.com/keystonejs/keystone/commit/57c98c90ee4220bcc59925a154a231989d25de51) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `@hapi/iron` to `^6.0.0`.

* [#5068](https://github.com/keystonejs/keystone/pull/5068) [`ed3c98839`](https://github.com/keystonejs/keystone/commit/ed3c988392bce981ef7d81c1eb14a045c6198da8) Thanks [@rohan-deshpande](https://github.com/rohan-deshpande)! - Fixed issue where createKeystone would call prisma migrate dev when the build script was run

* Updated dependencies [[`3eabc35e0`](https://github.com/keystonejs/keystone/commit/3eabc35e0d41b60449ff456e9a0ec3eabf360508)]:
- @keystone-next/adapter-knex-legacy@13.2.0

## 11.0.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages-next/keystone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@keystone-next/keystone",
"version": "11.0.1",
"version": "11.0.2",
"license": "MIT",
"main": "dist/keystone.cjs.js",
"module": "dist/keystone.esm.js",
Expand All @@ -15,7 +15,7 @@
"@graphql-tools/schema": "^7.1.3",
"@graphql-tools/utils": "^7.5.2",
"@hapi/iron": "^6.0.0",
"@keystone-next/adapter-knex-legacy": "^13.1.0",
"@keystone-next/adapter-knex-legacy": "^13.2.0",
"@keystone-next/adapter-mongoose-legacy": "^11.1.0",
"@keystone-next/adapter-prisma-legacy": "3.2.0",
"@keystone-next/admin-ui": "^10.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages-next/keystone/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { createSystem } from './lib/createSystem';
export { createExpressServer } from './lib/createExpressServer';
export { initConfig } from './lib/initConfig';
export { createApolloServerMicro } from './lib/createApolloServerMicro';
export { createApolloServerMicro } from './lib/createApolloServer';
79 changes: 79 additions & 0 deletions packages-next/keystone/src/lib/createApolloServer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import type { IncomingMessage, ServerResponse } from 'http';
import { GraphQLSchema } from 'graphql';
import { ApolloServer as ApolloServerMicro } from 'apollo-server-micro';
import { ApolloServer as ApolloServerExpress } from 'apollo-server-express';

// @ts-ignore
import { formatError } from '@keystone-next/keystone-legacy/lib/Keystone/format-error';
import type { CreateContext, SessionStrategy } from '@keystone-next/types';
import { createSessionContext } from '../session';

export const createApolloServerMicro = ({
graphQLSchema,
createContext,
sessionStrategy,
connectionPromise,
}: {
graphQLSchema: GraphQLSchema;
createContext: CreateContext;
sessionStrategy?: SessionStrategy<any>;
connectionPromise: Promise<any>;
}) => {
return new ApolloServerMicro({
uploads: false,
schema: graphQLSchema,
playground: { settings: { 'request.credentials': 'same-origin' } },
formatError,
context: async ({ req, res }: { req: IncomingMessage; res: ServerResponse }) => {
await connectionPromise;
return createContext({
sessionContext: sessionStrategy
? await createSessionContext(sessionStrategy, req, res, createContext)
: undefined,
req,
});
},
});
};

export const createApolloServerExpress = ({
graphQLSchema,
createContext,
sessionStrategy,
}: {
graphQLSchema: GraphQLSchema;
createContext: CreateContext;
sessionStrategy?: SessionStrategy<any>;
}) => {
return new ApolloServerExpress({
uploads: false,
schema: graphQLSchema,
// FIXME: allow the dev to control where/when they get a playground
playground: { settings: { 'request.credentials': 'same-origin' } },
formatError, // TODO: this needs to be discussed
context: async ({ req, res }: { req: IncomingMessage; res: ServerResponse }) =>
createContext({
sessionContext: sessionStrategy
? await createSessionContext(sessionStrategy, req, res, createContext)
: undefined,
req,
}),
// FIXME: support for apollo studio tracing
// ...(process.env.ENGINE_API_KEY || process.env.APOLLO_KEY
// ? { tracing: true }
// : {
// engine: false,
// // Only enable tracing in dev mode so we can get local debug info, but
// // don't bother returning that info on prod when the `engine` is
// // disabled.
// tracing: dev,
// }),
// FIXME: Support for generic custom apollo configuration
// ...apolloConfig,
});
// FIXME: Support custom API path via config.graphql.path.
// Note: Core keystone uses '/admin/api' as the default.
// FIXME: Support for file handling configuration
// maxFileSize: 200 * 1024 * 1024,
// maxFiles: 5,
};
30 changes: 0 additions & 30 deletions packages-next/keystone/src/lib/createApolloServerMicro.ts

This file was deleted.

38 changes: 2 additions & 36 deletions packages-next/keystone/src/lib/createExpressServer.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import type { IncomingMessage, ServerResponse } from 'http';
import cors, { CorsOptions } from 'cors';
import express from 'express';
import { GraphQLSchema } from 'graphql';
import { ApolloServer } from 'apollo-server-express';
import { graphqlUploadExpress } from 'graphql-upload';
// @ts-ignore
import { formatError } from '@keystone-next/keystone-legacy/lib/Keystone/format-error';
import type { KeystoneConfig, CreateContext, SessionStrategy } from '@keystone-next/types';
import { createAdminUIServer } from '@keystone-next/admin-ui/system';
import { createSessionContext } from '../session';
import { createApolloServerExpress } from './createApolloServer';

const addApolloServer = ({
server,
Expand All @@ -21,37 +17,7 @@ const addApolloServer = ({
createContext: CreateContext;
sessionStrategy?: SessionStrategy<any>;
}) => {
const apolloServer = new ApolloServer({
uploads: false,
schema: graphQLSchema,
// FIXME: allow the dev to control where/when they get a playground
playground: { settings: { 'request.credentials': 'same-origin' } },
formatError, // TODO: this needs to be discussed
context: async ({ req, res }: { req: IncomingMessage; res: ServerResponse }) =>
createContext({
sessionContext: sessionStrategy
? await createSessionContext(sessionStrategy, req, res, createContext)
: undefined,
req,
}),
// FIXME: support for apollo studio tracing
// ...(process.env.ENGINE_API_KEY || process.env.APOLLO_KEY
// ? { tracing: true }
// : {
// engine: false,
// // Only enable tracing in dev mode so we can get local debug info, but
// // don't bother returning that info on prod when the `engine` is
// // disabled.
// tracing: dev,
// }),
// FIXME: Support for generic custom apollo configuration
// ...apolloConfig,
});
// FIXME: Support custom API path via config.graphql.path.
// Note: Core keystone uses '/admin/api' as the default.
// FIXME: Support for file handling configuration
// maxFileSize: 200 * 1024 * 1024,
// maxFiles: 5,
const apolloServer = createApolloServerExpress({ graphQLSchema, createContext, sessionStrategy });
server.use(graphqlUploadExpress());
apolloServer.applyMiddleware({ app: server, path: '/api/graphql', cors: false });
};
Expand Down
6 changes: 6 additions & 0 deletions packages/adapter-knex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @keystonejs/adapter-knex

## 13.2.0

### Minor Changes

- [#5049](https://github.com/keystonejs/keystone/pull/5049) [`3eabc35e0`](https://github.com/keystonejs/keystone/commit/3eabc35e0d41b60449ff456e9a0ec3eabf360508) Thanks [@renovate](https://github.com/apps/renovate)! - Updated `knex` dependency to `^0.95.1`.

## 13.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-knex/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@keystone-next/adapter-knex-legacy",
"description": "KeystoneJS Knex Database Adapter",
"version": "13.1.0",
"version": "13.2.0",
"author": "The KeystoneJS Development Team",
"license": "MIT",
"engines": {
Expand Down
2 changes: 0 additions & 2 deletions packages/app-next/.npmignore

This file was deleted.

Loading

0 comments on commit fa242ff

Please sign in to comment.