-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: making login request with apollo client
- Loading branch information
1 parent
3b60336
commit b5158d2
Showing
8 changed files
with
239 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"schema": "http://localhost:8000/graphql" | ||
} |
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,10 @@ | ||
import { ApolloClient, InMemoryCache } from "@apollo/client"; | ||
|
||
const createApolloClient = () => { | ||
return new ApolloClient({ | ||
uri: "http://localhost:8000/graphql", | ||
cache: new InMemoryCache(), | ||
}); | ||
}; | ||
|
||
export default createApolloClient; |
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
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,34 @@ | ||
"use client"; | ||
import { ApolloClient, ApolloLink, HttpLink } from "@apollo/client"; | ||
import { | ||
ApolloNextAppProvider, | ||
NextSSRApolloClient, | ||
NextSSRInMemoryCache, | ||
SSRMultipartLink, | ||
} from "@apollo/experimental-nextjs-app-support/ssr"; | ||
|
||
function makeClient() { | ||
const httpLink = new HttpLink({ | ||
uri: "http://localhost:8000/graphql", | ||
}); | ||
|
||
return new NextSSRApolloClient({ | ||
cache: new NextSSRInMemoryCache(), | ||
link: | ||
typeof window === "undefined" | ||
? ApolloLink.from([ | ||
// in a SSR environment, if you use multipart features like | ||
// @defer, you need to decide how to handle these. | ||
// This strips all interfaces with a `@defer` directive from your queries. | ||
new SSRMultipartLink({ | ||
stripDefer: true, | ||
}), | ||
httpLink, | ||
]) | ||
: httpLink, | ||
}); | ||
} | ||
|
||
export function ApolloWrapper({ children }: React.PropsWithChildren) { | ||
return <ApolloNextAppProvider makeClient={makeClient}>{children}</ApolloNextAppProvider>; | ||
} |
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 @@ | ||
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client"; | ||
import { registerApolloClient } from "@apollo/experimental-nextjs-app-support/rsc"; | ||
|
||
const GRAPHQL_ENDPOINT = "http://localhost:8000/graphql"; | ||
|
||
export const { getClient } = registerApolloClient(() => { | ||
return new ApolloClient({ | ||
cache: new InMemoryCache(), | ||
link: new HttpLink({ | ||
uri: GRAPHQL_ENDPOINT, | ||
}), | ||
}); | ||
}); |
Oops, something went wrong.