Comments (3)
You could edit kit/entry/server.js
and re-write it with Express if you wanted, but I wouldn't recommend it.
Koa uses Promises as route handlers, which makes it possible to have middleware that 'awaits' further handlers, and thus interact with different parts of the request. We use that in the 'timer' as shown here:
// It's useful to see how long a request takes to respond. Add the
// timing to a HTTP Response header
.use(async (ctx, next) => {
const start = ms.now();
await next(); // <--- this 'yields' to the next handler, and resumes when it's done!
const end = ms.parse(ms.since(start));
const total = end.microseconds + (end.milliseconds * 1e3) + (end.seconds * 1e6);
ctx.set('Response-Time', `${total / 1e3}ms`);
});
AFAIK, you can't use that pattern in express, which makes it harder for a kit like ReactQL to implement convenience handlers like the one above.
I'd recommend you spend a few mins on http://koajs.com/ - it's basically 90% express, but using async functions as route handlers and the route 'context' being passed as an explicit parameter. It's the same Node HTTP server under the hood.
from reactql.
Good point. Thanks for letting me know.
Does Graphql support subscriptions with Koa? I really need it for my current project.
from reactql.
Yes, check out http://dev.apollodata.com/tools/graphql-subscriptions/
It hasn't been implemented in the ReactQL kit, but might be something that's added later.
from reactql.
Related Issues (20)
- sass imported styles are null on server, but correct on client HOT 2
- Question: Is go to definition supposed to work for generated types? HOT 1
- Constantly Loosing Styles And Images Using Office Fabric UI
- 4.3.1.tar.gz not working HOT 3
- Can't run project - quick start HOT 1
- .nvmrc Missing HOT 1
- Hot Reload seems to be broken in master HOT 1
- [v3.2.0] How to disable SSR? HOT 3
- ReactQL3.0 entry acts funny trying to start server HOT 1
- Hydrate on Static Deploy HOT 1
- Adding Material UI Button cause emty page HOT 2
- css.ts localIdentName: "[local]-[hash:base64]", fail
- import X from "y" HOT 2
- Could not find "client" in the context or passed in as an option. Wrap the root component in an <ApolloProvider
- Default Apollo Hooks rather than generated HOC for Apollo Queries HOT 2
- Example for a MongoDB based server HOT 1
- Stuck during production build HOT 2
- ReactQL Starter Kit giving errors with 'npm start' HOT 4
- Unable to connect to graphqlhub.com HOT 6
- Any update for Apollo Client v3?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactql.