-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use client' | ||
|
||
import { TestGql } from '../ui/TestGql' | ||
|
||
// graphql demo | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<TestGql /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
'use client'; | ||
'use client' | ||
|
||
import { useMutation } from '@apollo/client'; | ||
import { graphql } from '@common/generated/graphql'; | ||
import { useMutation } from '@apollo/client' | ||
import { graphql } from '@common/generated/graphql' | ||
|
||
const greetMutation = graphql(`mutation Greet($name: String!) {\n greet(name: $name) {\n greeting\n }\n}`); | ||
const greetMutation = graphql('mutation Greet($name: String!) {\n greet(name: $name) {\n greeting\n }\n}') | ||
|
||
export const TestGql = () => { | ||
const [greet] = useMutation(greetMutation); | ||
const [greet, { data: greetResult, loading }] = useMutation(greetMutation) | ||
|
||
return ( | ||
<button | ||
onClick={() => { | ||
greet({ variables: { name: 'world' } }); | ||
}} | ||
> | ||
greet | ||
</button> | ||
); | ||
}; | ||
<div className="flex flex-col items-center justify-center h-screen"> | ||
<button | ||
onClick={() => { | ||
greet({ variables: { name: 'world' } }) | ||
}} | ||
> | ||
greet | ||
</button> | ||
|
||
{loading && <progress className="m-4 w-48" />} | ||
{greetResult && <div>{greetResult.greet?.greeting}</div>} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import NextAuth from 'next-auth'; | ||
import { authConfig } from './auth.config'; | ||
import NextAuth from 'next-auth' | ||
import { authConfig } from './auth.config' | ||
|
||
export default NextAuth(authConfig).auth; | ||
export default NextAuth(authConfig).auth | ||
|
||
export const config = { | ||
// https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher | ||
matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)'], | ||
}; | ||
// require login for these paths | ||
// https://nextjs.org/docs/app/building-your-application/routing/middleware | ||
matcher: ['/sample/:path'], | ||
} |