https://github.com/czystyl/apollo-link-computed-property
Apollo link for computed property directive for client side
https://github.com/czystyl/apollo-link-computed-property
apollo-link computed-properties graphql
Last synced: 2 months ago
JSON representation
Apollo link for computed property directive for client side
- Host: GitHub
- URL: https://github.com/czystyl/apollo-link-computed-property
- Owner: czystyl
- License: mit
- Created: 2018-04-18T11:21:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T21:18:58.000Z (about 7 years ago)
- Last Synced: 2024-04-14T06:01:15.638Z (about 1 year ago)
- Topics: apollo-link, computed-properties, graphql
- Language: JavaScript
- Homepage:
- Size: 88.9 KB
- Stars: 20
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apollo-link-computed-property
## This project is under heavy active development !!
[![Version][version-badge]][package]
[![downloads][downloads-badge]][npmtrends]
[![PRs Welcome][prs-badge]][prs]
[![MIT License][license-badge]][build]## Introduction
Apollo link for `@computed` directive support on client side.
> Check this directive for the [server](https://github.com/czystyl/apollo-link-computed-property) side.
# Table of Contents
* [Introduction](#introduction)
* [Installation](#installation)
* [Usage](#Usage)
* [Parameters](#parameters)
* [Contributing](#contributing)
* [TODO](#todo)
* [LICENSE](#license)# Installation
```
yarn add apollo-link-computed-property
```_This package requires [apollo-client](https://www.npmjs.com/package/apollo-client) as peer dependency_
# Usage
```js
const httpLink = createHttpLink({ uri: 'http://you-graphql-server/graphql' });const client = new ApolloClient({
cache: new InMemoryCache(),
link: ApolloLink.from([ComputedPropertyLink, httpLink]),
});
```Query:
```js
client.query({
query: gql`
{
me {
firstName
lastName
fullName @computed(value: "$me.firstName $me.lastName")
}
}
`,
});
```# Directive Parameters
Directive params:
### `value`: String
The computed value. It can contain fields defined within the current type.
> Remember to add prefix with the name of query root level
Example:
`@computed(value: "$me.firstName $me.lastName")`
`@computed(value: "$product.price $")`## Contributing
I would love to see your contribution. ❤️
For local development (and testing), all you have to do is to run `yarn` and then run server `yarn start:server` and client `yarn start:client`.
That will start the Apollo server with client and you are ready to contribute :tada:Run yarn test (try `--watch` flag) for unit tests (we are using Jest)
## TODO:
* [ ] Add types
* [x] Support for computing nested fields
* [ ] Support fragments# LICENSE
The MIT License (MIT) 2018 - Luke Czyszczonik -
[npm]: https://www.npmjs.com/
[node]: https://nodejs.org
[build-badge]: https://img.shields.io/travis/czystyl/apollo-link-computed-property.svg?style=flat-square
[build]: https://travis-ci.org/graphql-community/graphql-directive-computed-property
[coverage-badge]: https://img.shields.io/codecov/c/github/graphql-community/graphql-directive-computed-property.svg?style=flat-square
[coverage]: https://codecov.io/github/czystyl/apollo-link-computed-property
[version-badge]: https://img.shields.io/npm/v/graphql-directive-computed-property.svg?style=flat-square
[package]: https://www.npmjs.com/package/graphql-directive-computed-property
[downloads-badge]: https://img.shields.io/npm/dm/graphql-directive-computed-property.svg?style=flat-square
[npmtrends]: http://www.npmtrends.com/graphql-directive-computed-property
[license-badge]: https://img.shields.io/npm/l/graphql-directive-computed-property.svg?style=flat-square
[license]: https://github.com/czystyl/apollo-link-computed-property/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com
[donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/czystyl/apollo-link-computed-property/blob/master/CODE_OF_CONDUCT.md