@@ -12,6 +12,7 @@ const { getMainDefinition } = require('apollo-utilities');
12
12
const { createUploadLink } = require ( 'apollo-upload-client' ) ;
13
13
const { SubscriptionClient } = require ( 'subscriptions-transport-ws' ) ;
14
14
const { WebSocketLink } = require ( '@apollo/client/link/ws' ) ;
15
+ const { mergeSchemas } = require ( '@graphql-tools/schema' ) ;
15
16
const {
16
17
ApolloClient,
17
18
InMemoryCache,
@@ -133,28 +134,31 @@ describe('ParseGraphQLServer', () => {
133
134
} ) ;
134
135
135
136
describe ( 'applyGraphQL' , ( ) => {
136
- it ( 'should require an Express.js app instance' , ( ) => {
137
- expect ( ( ) => parseGraphQLServer . applyGraphQL ( ) ) . toThrow (
137
+ it ( 'should require an Express.js app instance' , async ( ) => {
138
+ await expectAsync ( parseGraphQLServer . applyGraphQL ( ) ) . toBeRejectedWith (
138
139
'You must provide an Express.js app instance!'
139
140
) ;
140
- expect ( ( ) => parseGraphQLServer . applyGraphQL ( { } ) ) . toThrow (
141
+ await expectAsync ( parseGraphQLServer . applyGraphQL ( { } ) ) . toBeRejectedWith (
141
142
'You must provide an Express.js app instance!'
142
143
) ;
143
- expect ( ( ) => parseGraphQLServer . applyGraphQL ( new express ( ) ) ) . not . toThrow ( ) ;
144
+ await expectAsync ( parseGraphQLServer . applyGraphQL ( new express ( ) ) ) . toBeResolved ( ) ;
144
145
} ) ;
145
146
146
- it ( 'should apply middlewares at config.graphQLPath' , ( ) => {
147
+ it ( 'should apply middlewares at config.graphQLPath' , async ( ) => {
147
148
let useCount = 0 ;
148
- expect ( ( ) =>
149
- new ParseGraphQLServer ( parseServer , {
150
- graphQLPath : 'somepath' ,
151
- } ) . applyGraphQL ( {
152
- use : path => {
153
- useCount ++ ;
154
- expect ( path ) . toEqual ( 'somepath' ) ;
155
- } ,
156
- } )
157
- ) . not . toThrow ( ) ;
149
+ const gqlServer = new ParseGraphQLServer ( parseServer , {
150
+ graphQLPath : 'somepath' ,
151
+ } ) ;
152
+ gqlServer . applyGraphQL ( {
153
+ use : server => {
154
+ useCount ++ ;
155
+ if ( typeof server === 'string' ) {
156
+ expect ( server ) . toEqual ( 'somepath' ) ;
157
+ } else {
158
+ expect ( server . stack [ 1 ] . regexp . toString ( ) ) . toEqual ( '/^somepath\\/?(?=\\/|$)/i' ) ;
159
+ }
160
+ } ,
161
+ } ) ;
158
162
expect ( useCount ) . toBeGreaterThan ( 0 ) ;
159
163
} ) ;
160
164
} ) ;
@@ -7697,8 +7701,8 @@ describe('ParseGraphQLServer', () => {
7697
7701
. map ( call => call . args [ 0 ] )
7698
7702
. sort ( )
7699
7703
) . toEqual ( [
7700
- 'Function 1NumberInTheBeggning could not be added to the auto schema because GraphQL names must match /^[_a-zA- Z][_a-zA-Z0-9]*$ /.' ,
7701
- 'Function double-barrelled could not be added to the auto schema because GraphQL names must match /^[_a-zA- Z][_a-zA-Z0-9]*$ /.' ,
7704
+ 'Function 1NumberInTheBeggning could not be added to the auto schema because GraphQL names must match /^ [_a - zA - Z][_a - zA - Z0 - 9] * $ /.' ,
7705
+ 'Function double-barrelled could not be added to the auto schema because GraphQL names must match /^ [_a - zA - Z][_a - zA - Z0 - 9] * $ /.' ,
7702
7706
] ) ;
7703
7707
} catch ( e ) {
7704
7708
handleError ( e ) ;
@@ -10381,7 +10385,7 @@ describe('ParseGraphQLServer', () => {
10381
10385
} ) ;
10382
10386
10383
10387
describe ( 'Custom API' , ( ) => {
10384
- describe ( 'GraphQL Schema Based ' , ( ) => {
10388
+ describe ( 'SDL based ' , ( ) => {
10385
10389
let httpServer ;
10386
10390
const headers = {
10387
10391
'X-Parse-Application-Id' : 'test' ,
@@ -10504,7 +10508,7 @@ describe('ParseGraphQLServer', () => {
10504
10508
} ) ;
10505
10509
} ) ;
10506
10510
10507
- describe ( 'SDL Based' , ( ) => {
10511
+ describe ( 'GraphQL Schema Based' , ( ) => {
10508
10512
let httpServer ;
10509
10513
const headers = {
10510
10514
'X-Parse-Application-Id' : 'test' ,
@@ -10801,8 +10805,7 @@ describe('ParseGraphQLServer', () => {
10801
10805
httpServer = http . createServer ( expressApp ) ;
10802
10806
parseGraphQLServer = new ParseGraphQLServer ( parseServer , {
10803
10807
graphQLPath : '/graphql' ,
10804
- graphQLCustomTypeDefs : ( { autoSchema, stitchSchemas } ) =>
10805
- stitchSchemas ( { subschemas : [ autoSchema ] } ) ,
10808
+ graphQLCustomTypeDefs : ( { autoSchema } ) => mergeSchemas ( { schemas : [ autoSchema ] } ) ,
10806
10809
} ) ;
10807
10810
10808
10811
parseGraphQLServer . applyGraphQL ( expressApp ) ;
0 commit comments