apollo-link-optimistic
An Apollo Link that immediately returns an optimistic response provided in the context of the request, before returning the server response(s).
Install
npm install apollo-link-optimistic
or
yarn add apollo-link-optimsitic
Usage
;;;; ; thislink = ApolloLink; const optimisticResponse = data: hello: 'Optimistic World' ; const op = query: gql`{ hello }` context: // OptimisticLink gets the optimistic response from the context. optimisticResponse ; link; // Assuming the server responds with { data: { hello: "Server World" } }// This code will output:// "Optimistic World"// "Server World"// "complete!"