@@ -2,10 +2,10 @@ import * as express from 'express';
22import { default as expressPlayground } from "graphql-playground-middleware-express" ;
33import { express as voyagerMiddleware } from "graphql-voyager/middleware" ;
44import { altairExpress } from "altair-express-middleware" ;
5- import { graphql , ObjectTypeComposer , schemaComposer } from "graphql-compose" ;
5+ import { graphql , ObjectTypeComposer , printSchema , schemaComposer } from "graphql-compose" ;
66import { composeWithElastic } from "graphql-compose-elasticsearch" ;
77import * as elasticsearch from "elasticsearch" ;
8- import { ApolloServer } from "apollo-server-express" ;
8+ import { ApolloServer , gql } from "apollo-server-express" ;
99import { buildFederatedSchema } from "./buildFederatedSchema" ;
1010
1111const { GraphQLSchema, GraphQLObjectType } = graphql ;
@@ -223,10 +223,6 @@ const EcommerceEsTC = composeWithElastic({
223223 elasticType : '_doc' ,
224224 elasticMapping : ecommerceMapping ,
225225 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'],*/
230226} ) ;
231227
232228const ProxyTC = ObjectTypeComposer . createTemp ( `type ProxyDebugType { source: JSON }` ) ;
@@ -249,6 +245,23 @@ EcommerceEsTC.addRelation('showRelationArguments', {
249245 }
250246} ) ;
251247
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+
252265const generatedSchema = new GraphQLSchema ( {
253266 query : new GraphQLObjectType ( {
254267 name : 'Query' ,
@@ -262,12 +275,7 @@ const generatedSchema = new GraphQLSchema({
262275 // check and change result here before returning it to user
263276 console . log ( result ) ;
264277 return result ;
265- } ) . getFieldConfig ( ) /*,
266- elastic75: elasticApiFieldConfig({
267- host: 'http://elastic:changeme@localhost :9200',
268- apiVersion: '7.5'/!*,
269- log: 'trace',*!/
270- })*/
278+ } ) . getFieldConfig ( )
271279 } ,
272280 } ) ,
273281} ) ;
@@ -293,9 +301,3 @@ app.listen(expressPort, () => {
293301 console . log ( `The server is running at http://localhost:${ expressPort } /` ) ;
294302} ) ;
295303
296-
297- const inventory = [
298- { upc : "1" , inStock : true } ,
299- { upc : "2" , inStock : false } ,
300- { upc : "3" , inStock : true }
301- ] ;
0 commit comments