All Projects → eversport → ts-react-apollo

eversport / ts-react-apollo

Licence: MIT License
Thin-Layer around react apollo client to use typescript to the fullest

Programming Languages

typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to ts-react-apollo

Productivity Frontend
Productivity Application - Kanban Style Productivity Management Application with Customizable Boards, Lists and Cards to Make You More Productive.
Stars: ✭ 234 (+1200%)
Mutual labels:  graphql-client, apollo-client
edgestack
[UNMAINTAINED] A Universal React Stack with deeply integrated localization Support, semi-automatic route-based code splitting, Hot Module Reloading (HMR), Redux, Apollo GraphQL and more...
Stars: ✭ 77 (+327.78%)
Mutual labels:  graphql-client, apollo-client
uzual-mobile
Feed your brains with habits for a better mood
Stars: ✭ 67 (+272.22%)
Mutual labels:  graphql-client, apollo-client
Kikstart Graphql Client
🚀 Small NodeJS Wrapper around apollo-client that provides easy access to running queries, mutations and subscriptions.
Stars: ✭ 27 (+50%)
Mutual labels:  graphql-client, apollo-client
Angular1 Apollo
AngularJS integration for the Apollo Client
Stars: ✭ 108 (+500%)
Mutual labels:  graphql-client, apollo-client
Apollo Angular
A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
Stars: ✭ 1,058 (+5777.78%)
Mutual labels:  graphql-client, apollo-client
Apollo Client
🚀  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
Stars: ✭ 17,070 (+94733.33%)
Mutual labels:  graphql-client, apollo-client
Apollo Link
🔗 Interface for fetching and modifying control flow of GraphQL requests
Stars: ✭ 1,434 (+7866.67%)
Mutual labels:  graphql-client, apollo-client
gatsby-starter-redux-saas
An Gatsby starter for Saas products. Uses redux and apollo and a graphql token auth backend.
Stars: ✭ 18 (+0%)
Mutual labels:  graphql-client, apollo-client
nextjs-graphql-adminpanel
Admin panel built with NextJS(Typescript), Material UI, Apollo Client & GraphQL. In the backend, Prisma 2 with Nexus and Mysql is used.
Stars: ✭ 119 (+561.11%)
Mutual labels:  apollo-client
stuyspec.com
🖼 The Stuyvesant Spectator's website, built with React, GraphQL, and Rails.
Stars: ✭ 22 (+22.22%)
Mutual labels:  graphql-client
react-apollo-client-testing-example
A React with Apollo Client application with a mocked GraphQL server and tested Query and Mutation components.
Stars: ✭ 17 (-5.56%)
Mutual labels:  apollo-client
ember-boilerplate
👓 The stable base upon which we build our Ember.js projects at Mirego.
Stars: ✭ 33 (+83.33%)
Mutual labels:  apollo-client
fullstack-graphql-angular
Simple Fullstack GraphQL Application with Angular CLI + Redux. API built with Typescript + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with Angular CLI + Redux + Async Middleware to access the API.
Stars: ✭ 67 (+272.22%)
Mutual labels:  graphql-client
apollo-typescript-example
Apollo Client 2.0 + TypeScript example
Stars: ✭ 17 (-5.56%)
Mutual labels:  apollo-client
SimpleXamarinGraphQL
An iOS and Android app built in Xamarin.Forms demonstrating how to interact with GitHub's GraphQL API
Stars: ✭ 18 (+0%)
Mutual labels:  graphql-client
recompose-apollo
Recompose HOCs for React Apollo
Stars: ✭ 36 (+100%)
Mutual labels:  apollo-client
UmaSupporter.WebClient
🏃🏽‍♀️ 우마무스메 육성 도우미 '우마서포터'의 프론트엔드 애플리케이션입니다.
Stars: ✭ 14 (-22.22%)
Mutual labels:  apollo-client
now-course
Proyecto para el curso de Now.sh en Platzi
Stars: ✭ 19 (+5.56%)
Mutual labels:  apollo-client
fittrak
A data-driven workout tracking tool for the quantified-self 💪 🤓
Stars: ✭ 19 (+5.56%)
Mutual labels:  apollo-client

DEPRECATED

Since there now is amazing hook support which makes using react-apollo way easier this project is discontinued

TypeScript React Apollo

This package uses react-apollo under the hood, but does change the result type to tailer it to make use of helpful TypeScript features for a better developer experience. For example using exhaustive matching against Discriminated Unions for the Query render prop.

Installation

https://www.npmjs.com/package/ts-react-apollo

npm i ts-react-apollo
# in case you prefer yarn use
yarn add ts-react-apollo

If you would like us to support other ways of using ts-react-apollo please open an issue.

API

Query

Instead of returning data, loading and error it returns a result which is a Discriminated Union with the property type being the discriminant. Why? Because these states can't happen at the same time. loading and error for example can never be true at the same time.

Using a switch statment with an assetNever default case we can do exhaustive checking on all the possible states.

interface ProfileData {
  github: {
    user: {
      avatar_url: string;
      login: string;
    };
  };
}

const Profile = () => (
  <Query<ProfileData> query={getProfile}>
    {({ result }) => {
      switch (result.type) {
        case "loading":
          return "Loading …";
        case "error":
          return "Sorry, something went wrong";
        case "data":
          return (
            <div>
              <img
                src={result.data.github.user.avatar_url}
                alt={`${result.data.github.user.login} Avatar`}
              />
            </div>
          );
        default:
          return assertNever(result);
      }
    }}
  </Query>
);

Info: To keep the return value as simple as possible the current query component does not support the notifyOnNetworkStatusChange property. If you feel that we should add this please create an issue and describe the possible use case that you experience.

You can find the working example in the repository.

Todo

  • Add API documentation
  • Add tests
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].