oc-graphql-client
NOTICE!
- The current released version (3.*) does not use the Apollo client due to memory consumption issues.
- The client does not expose a querybuilder, instead just use a raw string as the examples does.
A OpenComponents plugin that expose the a graphql client for interacting with a GraphQL based server.
Requirements:
- OC Registry
- GraphQL Server
- Node >= v6
Install
yarn add oc-graphql-client
Registry setup
More info about integrating OC plugins: here
...var registry = configuration; registry; ... registrystartcallback;
Register API
parameter | type | mandatory | description |
---|---|---|---|
serverUrl | string |
yes | The Url for the GraphQL server |
Usage
Example for a components' server.js:
moduleexports{ const query = ` query restaurantInfo($id: Int!) { restaurant(id: $id) { name } }`; const headers = 'accept-language': 'en-US, en' ; contextpluginsgraphql
API
parameter | type | mandatory | description |
---|---|---|---|
options | object |
yes | A composite of the query & variables to pass to GraphQL server |
headers | object |
no | The headers to pass down to unerlying services |
timeout | int |
no | The timeout in ms. It defaults to OS default |
Contributing
PR's are welcome!
License
MIT