-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add example for Next 13 app
directory and Keystone getContext
#8371
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 91e011e:
|
@borisno2 Thanks for this, I was struggling with this when I tried your work in "On The Hill Drama" in my repo. For auth I think having default keystone based login in admin-ui should be possible with some changes. |
No worries @gautamsi I am hoping to create some more videos over the coming weeks covering how I did auth (using next-auth) and vercel deployment, let me know if you think there would be other things that would be valuable to cover |
It would be valuable to use in built authentication instead of next-auth to start with, next-auth is add-on and even better way to do things but in-built stuffs should work. |
any update on this? |
99f0e8a
to
26db5cc
Compare
if I add
this allows me to run the PR with document field |
app
directory and Keystone getContext
c7e69fd
to
99d7c34
Compare
8c3da68
to
d11b350
Compare
app
directory and Keystone getContext
app
directory and Keystone getContext
d252ad8
to
81ed2fb
Compare
2fa21c2
to
a666fe6
Compare
62af1a9
to
b831ed8
Compare
It’s looking good 😄 The NextJS Beta docs are encouraging the I’d like to see an example of the It may be good to reference the Ahh, So glad to see this example 🎉 |
Authentication is hard. I think it is easier for us to have authentication in a few examples, maintain them really well, and then keep the rest of the examples authentication free. Interested to hear if you think otherwise 💛 |
Thanks!
Agreed, although route handlers also need to be supported by the GraphQL server - in this case
I have just recorded a video of how I am doing this in my project. Would love some feedback, as @dcousens mentioned it is hard to make a generic example as Authentication is hard and often very project specific, or any example would just go into how to use next-auth or some other provider.
Good callout, I haven't run into that issue, but maybe that is due to our use of a custom Prisma Client location. How do you think this is best to be called out?
Glad it is helpful! |
Definitely. I always try to lean on a framework or library to support it. Authentication is hard to get right.
Sure! I noticed you’re working on a supabase example in https://github.com/keystonejs/keystone/pull/8469/files There was only one auth example, so that’s why I’m interested in more details.
I think that social auth is important though. Examples with some of these libraries would be very helpful:
With
I think a workaround may be including the yoga server in both the
I think both that and KeystoneJS has done very well with access control. I like how it manages access to both the API and UI, with support for roles and granular permissions. It’s really well done. It’s the authentication pieces that are still complex, especially since a lot of functionality and examples are not built into core.
Awesome! I’ll check that out later tonight. Thank you |
@borisno2 coming back to this discussion.
graphql-yoga added the next.js app router examples to their docs here dotansimha/graphql-yoga#2760 basic example: import { createSchema, createYoga } from 'graphql-yoga'
const { handleRequest } = createYoga({
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () => 'This is the `greetings` field of the root `Query` type'
}
}
}),
// While using Next.js file convention for routing, we need to configure Yoga to use the correct endpoint
graphqlEndpoint: '/api/graphql',
// Yoga needs to know how to create a valid Next response
fetchAPI: { Response }
})
export { handleRequest as GET, handleRequest as POST } unfortunately with the app router its not possible to do |
Hey @mmachatschek |
We loving hearing feedback like this @mmachatschek as it helps us understand what abstractions might better serve us in respect to things like our |
Adding Keystone in the Nextjs app directory example showing how to use
getContext
within Server Rendered Components. This example uses the document renderer, the scope of the example is not to show how authentication or session management should work - the suggestion at this stage is to usecontext.withSession