@@ -2,10 +2,10 @@ import * as express from 'express';
2
2
import { default as expressPlayground } from "graphql-playground-middleware-express" ;
3
3
import { express as voyagerMiddleware } from "graphql-voyager/middleware" ;
4
4
import { altairExpress } from "altair-express-middleware" ;
5
- import { graphql , ObjectTypeComposer , schemaComposer } from "graphql-compose" ;
5
+ import { graphql , ObjectTypeComposer , printSchema , schemaComposer } from "graphql-compose" ;
6
6
import { composeWithElastic } from "graphql-compose-elasticsearch" ;
7
7
import * as elasticsearch from "elasticsearch" ;
8
- import { ApolloServer } from "apollo-server-express" ;
8
+ import { ApolloServer , gql } from "apollo-server-express" ;
9
9
import { buildFederatedSchema } from "./buildFederatedSchema" ;
10
10
11
11
const { GraphQLSchema, GraphQLObjectType } = graphql ;
@@ -223,10 +223,6 @@ const EcommerceEsTC = composeWithElastic({
223
223
elasticType : '_doc' ,
224
224
elasticMapping : ecommerceMapping ,
225
225
elasticClient : elasticClient
226
- /*,
227
- // elastic mapping does not contain information about is fields are arrays or not
228
- // so provide this information explicitly for obtaining correct types in GraphQL
229
- pluralFields: ['skills', 'languages'],*/
230
226
} ) ;
231
227
232
228
const ProxyTC = ObjectTypeComposer . createTemp ( `type ProxyDebugType { source: JSON }` ) ;
@@ -249,6 +245,23 @@ EcommerceEsTC.addRelation('showRelationArguments', {
249
245
}
250
246
} ) ;
251
247
248
+ let ContentTC = schemaComposer . createObjectTC ( `
249
+ extend type Content @key(fields: "id") {
250
+ id: String! @external
251
+ ecommerces: [ecommerceecommerce]
252
+ }
253
+ ` ) ;
254
+
255
+ let typesFieldsResolve = {
256
+ 'Content' : {
257
+ 'ecommerces' :( source , args , context , info ) => {
258
+ console . log ( "Here I am" ) ;
259
+ return null ;
260
+ }
261
+ }
262
+ } ;
263
+ schemaComposer . addResolveMethods ( typesFieldsResolve ) ;
264
+
252
265
const generatedSchema = new GraphQLSchema ( {
253
266
query : new GraphQLObjectType ( {
254
267
name : 'Query' ,
@@ -262,12 +275,7 @@ const generatedSchema = new GraphQLSchema({
262
275
// check and change result here before returning it to user
263
276
console . log ( result ) ;
264
277
return result ;
265
- } ) . getFieldConfig ( ) /*,
266
- elastic75: elasticApiFieldConfig({
267
- host: 'http://elastic:changeme@localhost :9200',
268
- apiVersion: '7.5'/!*,
269
- log: 'trace',*!/
270
- })*/
278
+ } ) . getFieldConfig ( )
271
279
} ,
272
280
} ) ,
273
281
} ) ;
@@ -293,9 +301,3 @@ app.listen(expressPort, () => {
293
301
console . log ( `The server is running at http://localhost:${ expressPort } /` ) ;
294
302
} ) ;
295
303
296
-
297
- const inventory = [
298
- { upc : "1" , inStock : true } ,
299
- { upc : "2" , inStock : false } ,
300
- { upc : "3" , inStock : true }
301
- ] ;
0 commit comments