2

Context

Today I have a simple GraphQL stitching server that unify two graphql applications into a single graphql endpoint

AS IS

It works introspecting each service (app 1 & app 2) and building an ApolloLink assigning a host url to each app with apollo-upload-client and apollo-link-http.

enter image description here

After this I Merge both schemas using mergeSchemas from graphql-tools libray.

Problem

Now I have to consume another service that is equal to app 1 but it uses another database, consequently another url, but when i instantiate the app 1 apollo-link using a diferente host the mergeSchemas ignores it and the final stitched schema continue as it initial state.

How to use the same schema with different URL's?

TO BE

I want to stitch 2 similar schemas using different url's enter image description here

UPDATE

I've instantiate the schemas multiple times using different urls for each one, but this gave me duplicate schemas. whitch solves my problem but i think that there are better solutions to keep with the same schema and switch hosts by a header, for example.

enter image description here

Is there any better solution to keep just with 2 schemas?

  • If there is no parameter/identifier to switch between same schemas, what's the point of stitching? Wouldn't it become a load balancing problem? – Doğancan Arabacı Dec 14 '18 at 13:33
  • @DoğancanArabacı, no, because I have app 1 running in different environments with different data, and sometimes from my stitching i want to access app1 in http://europe.service1.com/graphql and sometimes from http://asia.service1.com/graphql. – Andre Torbitoni Dec 14 '18 at 16:57
  • in that case, there is a business logic to access different data source. Which is not part of your gql schemas, hence the issue. In that case you can only differentiate by a parameter, header or schema. I hope someone answers with a better solution :D – Doğancan Arabacı Dec 17 '18 at 09:46

0 Answers0