Closed hoangvvo closed 2 years ago
How to use it with GrahQL
If I use it in my production build, how difficult could it be to switch to expressjs later?
You can always switch to express by replace nc()
with express()
. Regarding GraphQL, you probably use it with something like express-graphql, in which case their example works simply by replacing express()
with nc()
What about using GraphQL with next-connect? And even if I achieve it will it work on Vercel serverless?
It definitely works:
// api/graphql.js
const nc = require("next-connect");
const { graphqlHTTP } = require("express-graphql");
module.exports = nc()
.use(middleware)
.all(graphqlHTTP({
schema: MyGraphQLSchema
}));
Would it be smart to include support for the new middleware support in Next.js? Or do you see that as a v2? Or never ;-)
Would it be smart to include support for the new middleware support in Next.js? Or do you see that as a v2? Or never ;-)
It is totally possible. I am just wondering what would be a good naming for this functionality:
import nc from "next-connect/next-middleware
// or
import { middleware } from "next-connect"
I think I would go with the second one.
This library has been sitting in v0 for awhile. After a period of using it in several production apps, it does not seem to yield any problems. After all, most crux of this library depends on the awesome https://github.com/lukeed/trouter library, so nothing much can really go wrong.
Before the 1.0 release though:
http
very fine. Therefore, it should be about more than Next.js.