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

518 views Asked by At

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.

1

There are 1 answers

0
sagannotcarl On

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