Apollo link for @computed
directive support on client side.
Check this directive for the server side.
yarn add apollo-link-computed-property
This package requires apollo-client as peer dependency
const httpLink = createHttpLink({ uri: 'http://you-graphql-server/graphql' });
const client = new ApolloClient({
cache: new InMemoryCache(),
link: ApolloLink.from([ComputedPropertyLink, httpLink]),
});
Query:
client.query({
query: gql`
{
me {
firstName
lastName
fullName @computed(value: "$me.firstName $me.lastName")
}
}
`,
});
Directive params:
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 $")
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 🎉
Run yarn test (try --watch
flag) for unit tests (we are using Jest)
- Add types
- Support for computing nested fields
- Support fragments
The MIT License (MIT) 2018 - Luke Czyszczonik - mailto:lukasz.czyszczonik@gmail.com