简体   繁体   中英

How to create service for angular2 + apollo-client with graphql

I have no idea to create a service (like a api gateway) for send data that use apollo to my backend w/ graphql.

If i dont have a service. All of my components that want to send or get data from backend w/ graphql always import those 2

import { Angular2Apollo } from 'angular2-apollo';
import gql from 'graphql-tag';

I try to create a service for that but query and mutation function in apollo have many property so my service can't warp all of many property.

Or it not be able to create service for that.

Thanks.

Angular2 and Apollo Client are tools for creating a GraphQL client. You need to create a separate app that is a GraphQL server.

I suggest you create a new app and follow the instructions here: http://dev.apollodata.com/tools/graphql-server

Then you can work on making your Angular2 app make requests to the GraphQL server. For examples you can look here: http://dev.apollodata.com/angular2

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