All Projects → af → apollo-local-query

af / apollo-local-query

Licence: MIT license
Simpler server rendering with apollo-client 1.x, using a local GraphQL networkInterface

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to apollo-local-query

Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+2677.27%)
Mutual labels:  apollo, ssr, apollo-client
apollo-fragment
Use Apollo Link State to connect components to GraphQL fragments in the Apollo Cache
Stars: ✭ 112 (+69.7%)
Mutual labels:  apollo, apollo-client
nap
[Deprecated] NextJS + Apollo + PassportJS
Stars: ✭ 52 (-21.21%)
Mutual labels:  apollo, apollo-client
jest-gql
✅🚀GraphQL based tests for Jest and Apollo
Stars: ✭ 33 (-50%)
Mutual labels:  apollo, apollo-client
GitHunt-Polymer
An example of a client-side app built with Polymer and Apollo Client.
Stars: ✭ 13 (-80.3%)
Mutual labels:  apollo, apollo-client
matters-web
Website of Matters.News, built with Next.js.
Stars: ✭ 70 (+6.06%)
Mutual labels:  apollo, apollo-client
RxApolloClient
RxSwift extensions for Apollo Client
Stars: ✭ 46 (-30.3%)
Mutual labels:  apollo, apollo-client
Apollo Cache Redux
Redux cache for Apollo Client 2.0. This project is no longer maintained.
Stars: ✭ 179 (+171.21%)
Mutual labels:  apollo, apollo-client
gitstar
Github Client built with React Apollo
Stars: ✭ 15 (-77.27%)
Mutual labels:  apollo, apollo-client
agollo
🚀Go client for ctrip/apollo (https://github.com/apolloconfig/apollo)
Stars: ✭ 563 (+753.03%)
Mutual labels:  apollo, apollo-client
graphql-workshop
⚒ 🚧 A GraphQL workshop to learn GraphQL implementations
Stars: ✭ 20 (-69.7%)
Mutual labels:  apollo, apollo-client
bookshelf
My GraphQL playground
Stars: ✭ 64 (-3.03%)
Mutual labels:  apollo, apollo-client
ctrip-apollo
The most delightful and handy Node.js client for ctrip apollo configuration service.
Stars: ✭ 56 (-15.15%)
Mutual labels:  apollo, apollo-client
boilerplate
Boilerplate for @prisma-cms
Stars: ✭ 22 (-66.67%)
Mutual labels:  apollo, apollo-client
Kit
ReactQL starter kit (use the CLI)
Stars: ✭ 232 (+251.52%)
Mutual labels:  apollo, apollo-client
apollo-cache-instorage
Apollo Cache implementation that facilitates locally storing resources
Stars: ✭ 98 (+48.48%)
Mutual labels:  apollo, apollo-client
react-apollo-graphql
Get rid of decorators and use Apollo GraphQL queries and mutations in the simple and readable way.
Stars: ✭ 16 (-75.76%)
Mutual labels:  apollo, apollo-client
Ddp Apollo
DDP link for Apollo with GraphQL Subscriptions support
Stars: ✭ 163 (+146.97%)
Mutual labels:  apollo, apollo-client
Agollo
An elegant Go client for Ctrip Apollo
Stars: ✭ 167 (+153.03%)
Mutual labels:  apollo, apollo-client
laika
Log, test, intercept and modify Apollo Client's operations
Stars: ✭ 99 (+50%)
Mutual labels:  apollo, apollo-client

apollo-local-query

Build Status

A local GraphQL networkInterface for apollo-client 1.x. If you're using Apollo Client 2.x and above, you probably want to use SchemaLink instead!

This is useful for server-rendering a React/Apollo app when your GraphQL server is running in the same server process. Rather than go out and back through the networking stack (eg. connecting to localhost), with this module the query runs in the same process as your rendering code.

Installation

npm install --save apollo-local-query

This module uses several ES6 features, so nodejs v6.0 or above is required.

Basic Usage

const {createLocalInterface} = require('apollo-local-query')
const graphql = require('graphql')
const schema = require('path/to/your/graphql_schema')

const isServer = ...
const options = { ... }     // Your common ApolloClient options

if (isServer) {
    options.networkInterface = createLocalInterface(graphql, schema)
    options.ssrMode = true
}

const myClient = new ApolloClient(options)

Note: If you're compiling your server-side code, GraphQL should be imported using the namespace import syntax, as the default import syntax will return undefined. For example:

import * as graphql from 'graphql';

Logging Queries

This module uses debug to enable optional logging. To log each query that runs through this local interface (along with its execution time), launch your server with the DEBUG env var set to apollo-local. For example, DEBUG=apollo-local npm start

License

MIT

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].