-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be usable with nextjs #648
Comments
I would love this too, in typescript for sure it will be perfect for modern app! |
Status updateThis comment is a summary of findings and rough reflexions after blindly trying to get Nexus and Next to work together for a day. 1. Support serverless environmentsNextJS'
2. Custom entrypointYou might notice on the file structure above, that the nexus entrypoint is completely separated from its schema modules. That's because each file in the Also, each file name in that folder is used as api route. Nexus' default entrypoint file name is
3. Support
|
Support for es modules is shipped #720. It seems there are no issues with However, minor bump: The nextjs-blog app uses noEmit tsc compiler option. This conflicts with Nexus #702 which would see it marked as not usable. Also, when present, there is an error in the nexus build:
It seems that removing the noEmit option from tsconfig to satisfy Nexus has no impact on nextjs. E.g. --- edit Just discovered that nextjs is a bit more agressive than first thought about noEmit:
|
We've made some progress since @Weakky's post. The tsc compiler options and entrypoint issues have been largely resolved. Three major issues remain, ordered by how we think we will tackle them:
Support for serverless should enable users to do something like this.
// pages/api/graphql.ts
import { server, use } from 'nexus'
import { nextjs } from 'nexus-plugin-nextjs'
use(nextjs())
const handler = server.handler
export default handler
|
Update
Looking at some next steps
|
While we do not expect dev modes to be integrated at least for a while, we do think there should be a way to run nexus dev mode for just reflection. Currently it runs start but in the context of nextjs dev it is nextjs that is responsible for running the app.
|
Following up on graphql-nexus/nexus#648 (comment). We will need build to not emit, as that will be the job of nextjs. Therefore the comment references seems obsolete. NoEmit isn't in conflict, it is expected. Some ideas:
I think honouring tsconfig makes the most sense for us. However I don't think it negates #702. Instead a |
Hey everyone, thanks for following this issue. We have shipped this sprint (0.21.0) enough serverless support to unblock rough integration with nextjs. Check it out now at https://github.com/graphql-nexus/examples#nextjs. To keep things flowing we will close this issue and open new ones to track more specific integration improvements with nextjs, like build and dev mode unification. |
What
Make it easy to write projects with next + nexus
Why
Next is a popular way to write client apps
How
needs research
Notes
TODOs
Need an api forfeat: allow implementing interfaces in extendType graphql-nexus/nexus#774process.env.NEXUS_SHOULD_GENERATE_ARTIFACTS
or vercel/nextjs plugin that achieves samenexus dev --reflection
onDiagnostic callback graphql-nexus/nexus#648 (comment) Being able to run dev mode for just reflection would help (overlaps with what vscode plugin would/could do). Currently the nexus dev mode server is run but unused, since next hosts it in actuality. sourceTypes doesn't work with module entrypoints. graphql-nexus/nexus#797Big TODOs
nexus/sdk
... cli features as an api ... for creating a nextjs plugin (?)The text was updated successfully, but these errors were encountered: