Skip to content

Commit

Permalink
chore(next-auth): update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Apr 19, 2023
1 parent 55c80d0 commit 5a61a5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions examples/nextjs-auth/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import NextAuth from 'next-auth'
import NextAuth, { AuthOptions } from 'next-auth'
import GithubProvider from 'next-auth/providers/github'

export default NextAuth({
export const authOptions: AuthOptions = {
// Configure one or more authentication providers
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
})
}

export default NextAuth(authOptions)
7 changes: 4 additions & 3 deletions examples/nextjs-auth/pages/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { createYoga, createSchema } from 'graphql-yoga'

import type { NextApiRequest, NextApiResponse } from 'next'
import type { Session } from 'next-auth'
import { getSession } from 'next-auth/react'
import { getServerSession } from 'next-auth/next'
import { authOptions } from './auth/[...nextauth]'

export const config = {
api: {
Expand All @@ -21,9 +22,9 @@ export default createYoga<
session: Session
}
>({
context: async ({ req }) => {
context: async ({ req, res }) => {
return {
session: await getSession({ req }),
session: await getServerSession(req, res, authOptions),
}
},
schema: createSchema({
Expand Down

0 comments on commit 5a61a5a

Please sign in to comment.