Skip to content

how to change kitQLClient URL during runtime with process.env? #155

Answered by jycouet
N3rdArtiste asked this question in Q&A
Discussion options

You must be logged in to vote

Check out the Announcement here


Now you can hook up before or after the fetch,

Here is an example 👇

import type { RequestHandlerArgs } from '$houdini';
import { HoudiniClient } from '$houdini';
import { stry } from '@kitql/helper';

// For Query & Mutation
async function fetchQuery({
  fetch,
  text = '',
  variables = {},
  session,
  metadata
}: RequestHandlerArgs) {
  // Prepare the request
  const url = import.meta.env.VITE_GRAPHQL_ENDPOINT || 'http://localhost:4000/graphql';

  // regular fetch (Server & Client)
  const result = await fetch(url, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${session?.token}` // session u…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@N3rdArtiste
Comment options

@jycouet
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jycouet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants