Skip to content

Commit 92bfaf4

Browse files
lchudinovdhmlau
authored andcommitted
feat(graphql): migrate to apollo server 5
Signed-off-by: Leonty Chudinov <leonty.chudinov@gmail.com>
1 parent 861800c commit 92bfaf4

6 files changed

Lines changed: 132 additions & 144 deletions

File tree

extensions/graphql/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"@loopback/rest": "^15.0.1"
4545
},
4646
"dependencies": {
47-
"@apollo/server": "^4.13.0",
47+
"@apollo/server": "^5.5.1",
48+
"@as-integrations/express4": "^1.1.2",
4849
"@graphql-tools/utils": "^11.1.0",
4950
"@loopback/http-server": "^7.0.12",
5051
"body-parser": "^2.2.2",

extensions/graphql/src/__tests__/unit/graphql.server.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6-
import {ExpressContextFunctionArgument} from '@apollo/server/dist/esm/express4';
6+
import {ExpressContextFunctionArgument} from '@as-integrations/express4';
77
import {expect} from '@loopback/testlab';
88
import {
99
field,

extensions/graphql/src/graphql.container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6-
import {ExpressContextFunctionArgument} from '@apollo/server/dist/esm/express4';
6+
import {ExpressContextFunctionArgument} from '@as-integrations/express4';
77
import {
88
Binding,
99
BindingScope,

extensions/graphql/src/graphql.server.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@ import {
88
ApolloServerOptionsWithSchema,
99
BaseContext,
1010
} from '@apollo/server';
11-
import {ExpressMiddlewareOptions} from '@apollo/server/dist/esm/express4';
12-
import {expressMiddleware} from '@apollo/server/express4';
11+
import {
12+
ExpressMiddlewareOptions,
13+
expressMiddleware,
14+
} from '@as-integrations/express4';
1315
import {printSchemaWithDirectives} from '@graphql-tools/utils';
1416
import {
1517
Binding,
1618
BindingFromClassOptions,
1719
BindingKey,
1820
BindingScope,
19-
config,
2021
Constructor,
2122
Context,
2223
ContextTags,
24+
Server,
25+
config,
2326
createBindingFromClass,
2427
filterByTag,
2528
inject,
2629
lifeCycleObserver,
27-
Server,
2830
} from '@loopback/core';
2931
import {HttpServer} from '@loopback/http-server';
3032
import {RestBindings, RestServer} from '@loopback/rest';
@@ -38,10 +40,10 @@ import * as http from 'http';
3840
import * as https from 'https';
3941
import {
4042
AuthChecker,
41-
buildSchema,
4243
NonEmptyArray,
4344
ResolverInterface,
4445
BuildSchemaOptions as TypeGrahpQLBuildSchemaOptions,
46+
buildSchema,
4547
} from 'type-graphql';
4648
import {Middleware} from 'type-graphql/build/typings/typings/middleware';
4749
import {WebSocketServer} from 'ws';
@@ -174,7 +176,6 @@ export class GraphQLServer extends Context implements Server {
174176
const serverConfig = {
175177
...this.options.apollo,
176178
schema,
177-
status400ForVariableCoercionErrors: true,
178179
// plugins: [ApolloServerPluginDrainHttpServer({ httpServer: this.httpServer })],
179180
} as ApolloServerOptionsWithSchema<BaseContext>;
180181
const graphQLServer = new ApolloServer(serverConfig);

extensions/graphql/src/keys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6-
import {ExpressMiddlewareOptions} from '@apollo/server/dist/esm/express4';
6+
import {ExpressMiddlewareOptions} from '@as-integrations/express4';
77
import {BindingKey, Constructor, CoreBindings} from '@loopback/core';
88
import {AuthChecker, PubSub, ResolverData} from 'type-graphql';
99
import {GraphQLComponent} from './graphql.component';

0 commit comments

Comments
 (0)