Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 3.39 KB

README.md

File metadata and controls

111 lines (80 loc) · 3.39 KB

apollo-link-computed-property

This project is under heavy active development !!

Version downloads PRs Welcome MIT License

Introduction

Apollo link for @computed directive support on client side.

Check this directive for the server side.

Table of Contents

Installation

yarn add apollo-link-computed-property

This package requires apollo-client as peer dependency

Usage

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 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 🎉

Run yarn test (try --watch flag) for unit tests (we are using Jest)

TODO:

  • Add types
  • Support for computing nested fields
  • Support fragments

LICENSE

The MIT License (MIT) 2018 - Luke Czyszczonik - mailto:[email protected]