Back

GraphQL SSR SDK initialization

  • 0
  • Self Hosted
  • Auth
  • GraphQL
  • Web
Criffis
4 Apr, 2024, 17:33

Hi there, I asked a similar question before, sorry in advance. I'm now implementing this self-hosted (will use cloud as soon as 1.5 is released).

How do I initialize an SDK in SSR if I want to use GraphQL? https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-3

How do I hook onto that createSessionClient to query/mutate?

The GraphQL docs section only shows

TypeScript
const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1') // Your Appwrite Endpoint
    .setProject('<PROJECT_ID>');                // Your project ID

const graphql = new Graphql(client);

But that's for Client SDK. I need to hook on to the Account(client) account session somehow, right?

TL;DR
Developers want to initialize the Appwrite SDK in SSR to use GraphQL. They need to hook onto `createSessionClient` to query/mutate, which isn't clear in the documentation. To achieve this, developers should use the following code to initialize the SDK: ``` const client = new Client() .setEndpoint('https://cloud.appwrite.io/v1') // Your Appwrite Endpoint .setProject('<PROJECT_ID>'); // Your project ID const account = new Account(client); const graphql = new Graphql(client); ``` By adding `const account = new Account(client);`, developers can hook onto the
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more