简体   繁体   中英

Apollo Angular Graphql, How to use multiple enpoints?

 mydomain.com/graphql/tags

mydomain.com/graphql/user

 mydomain.com/graphql/friend

I've a server with graphql enpoints like this, each has it's own mutations and queries, how can i make a angular front end for it? I've searched a bit, but every tutorial shows how i can use a single graphql server on apollo client. Can anyone help?

You need to create a named client for each endpoint: https://www.apollographql.com/docs/angular/features/multiple-clients/

apollo.create(options, 'tags');

apollo.create(options, 'user');

apollo.create(options, 'friend');

Then, you can specify which client to use when querying:

apollo.use('tags').watchQuery({...});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM