@@ -8,7 +8,6 @@ import { SdrGql } from 'daf-selective-disclosure'
8
8
import merge from 'lodash.merge'
9
9
import { agent } from './setup'
10
10
import { listen } from './services'
11
- import { makeExecutableSchema , mergeSchemas } from 'graphql-tools'
12
11
import { getConfiguration } from './config'
13
12
14
13
program
@@ -20,66 +19,42 @@ program
20
19
. action ( async cmd => {
21
20
await agent
22
21
const { graphql } = getConfiguration ( )
23
- const schemas = [
24
- makeExecutableSchema ( {
25
- typeDefs : Gql . baseTypeDefs + Gql . Core . typeDefs ,
26
- resolvers : Gql . Core . resolvers
27
- } )
28
- ]
22
+ const typeDefs = [ Gql . baseTypeDefs , Gql . Core . typeDefs ]
23
+ let resolvers = Gql . Core . resolvers
29
24
30
25
if ( graphql . resolvers . IdentityManager ) {
31
- schemas . push (
32
- makeExecutableSchema ( {
33
- typeDefs : Gql . baseTypeDefs + Gql . IdentityManager . typeDefs ,
34
- resolvers : Gql . IdentityManager . resolvers
35
- } )
36
- )
26
+ typeDefs . push ( Gql . IdentityManager . typeDefs )
27
+ resolvers = merge ( resolvers , Gql . IdentityManager . resolvers )
37
28
}
38
29
39
30
if ( graphql . resolvers . TrustGraph ) {
40
- schemas . push (
41
- makeExecutableSchema ( {
42
- typeDefs : Gql . baseTypeDefs + TrustGraphGql . typeDefs ,
43
- resolvers : TrustGraphGql . resolvers
44
- } )
45
- )
31
+ typeDefs . push ( TrustGraphGql . typeDefs )
32
+ resolvers = merge ( resolvers , TrustGraphGql . resolvers )
46
33
}
47
34
48
35
if ( graphql . resolvers . DIDComm ) {
49
- schemas . push (
50
- makeExecutableSchema ( {
51
- typeDefs : Gql . baseTypeDefs + DIDCommGql . typeDefs ,
52
- resolvers : DIDCommGql . resolvers
53
- } )
54
- )
36
+ typeDefs . push ( DIDCommGql . typeDefs )
37
+ resolvers = merge ( resolvers , DIDCommGql . resolvers )
55
38
}
56
39
57
40
if ( graphql . resolvers . W3c ) {
58
- schemas . push (
59
- makeExecutableSchema ( {
60
- typeDefs : Gql . baseTypeDefs + W3cGql . typeDefs ,
61
- resolvers : W3cGql . resolvers
62
- } )
63
- )
41
+ typeDefs . push ( W3cGql . typeDefs )
42
+ resolvers = merge ( resolvers , W3cGql . resolvers )
64
43
}
65
44
66
45
if ( graphql . resolvers . Sdr ) {
67
- schemas . push (
68
- makeExecutableSchema ( {
69
- typeDefs : Gql . baseTypeDefs + SdrGql . typeDefs ,
70
- resolvers : SdrGql . resolvers
71
- } )
72
- )
46
+ typeDefs . push ( SdrGql . typeDefs )
47
+ resolvers = merge ( resolvers , SdrGql . resolvers )
73
48
}
74
49
75
- const schema = mergeSchemas ( { schemas } )
76
-
77
50
const server = new ApolloServer ( {
78
- schema,
51
+ typeDefs,
52
+ resolvers,
79
53
context : async ( { req } ) => {
80
54
if ( graphql . apiKey ) {
81
- const token = req . headers . authorization || ''
55
+ const token = req . headers . authorization || ''
82
56
if ( token !== 'Bearer ' + graphql . apiKey ) {
57
+ console . log ( { token} )
83
58
throw Error ( 'Auth error' )
84
59
}
85
60
}
0 commit comments