Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
ReactJs - How to wrap the ApolloProvider inside the StatsigProvider?

In react(nextjs) application, I am using statsig-react to switch the mastergraphql endpoint(urls). Now I am facing an issue while connecting statsig with apollo.

My app.js is like,

const apollo = useApollo(pageProps)

const AddStatsig = () => {
  <StatsigProvider
      sdkKey={`${env.statsigKey}`}
      options={{ environment: { tier: env.environment } }}
      waitForInitialization={true}
   >
     <Component {...pageProps} />
  </StatsigProvider>
}

return (
  <ApolloProvider client={apollo}>
   ...
   <AddStatsig />
   ...
  </ApolloProvider>
)

In apollo.js, I am changing uri like,

import { useGate } from 'statsig-react'

const statsigFeatureOn = useGate('newurl').value

const withAuth = createHttpLink({
  uri: statsigFeatureOn ? statsigPath : oldPath,
  fetch: awsGraphqlFetch,
})

Here, I am getting statsigFeatureOn as false always. And If I check the useGate value in any other component which is wrapped under the StatsigProvider there will get true value(required output).

If I wrap an ApolloProvider under StatsigProvider in a normal way will not get the desired output. I tried few ways and got the different kinds of errors and output.

How can I get true value inside apollo.js at initial load itself?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Move the ApolloProvider and related things into a new component and return that new component within the StatsigProvider in app.js. In new component get and pass the useGate value to useApollo hook.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!