fix: pass headers to apollo
This commit is contained in:
parent
9447bba00e
commit
d76040bb95
@ -14,6 +14,10 @@ function createApolloClient(headers) {
|
||||
}
|
||||
|
||||
export default function initializeApollo(initialState, headers) {
|
||||
if (isServer() && !headers) {
|
||||
throw new Error('initializeApollo: headers must be provided in server side');
|
||||
}
|
||||
|
||||
const _apolloClient = apolloClient ?? createApolloClient(headers);
|
||||
|
||||
// If your page has Next.js data fetching methods that use Apollo Client, the initial state
|
||||
|
||||
@ -13,9 +13,9 @@ export const eltKaskoRouter = router({
|
||||
eltKasko: protectedProcedure
|
||||
.input(EltInputSchema)
|
||||
.output(EltOutputSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const apolloClient = initializeApollo();
|
||||
const apolloClient = initializeApollo(null, ctx.headers);
|
||||
const store = new RootStore();
|
||||
store.$calculation.$values.hydrate(input.calculation.values);
|
||||
|
||||
|
||||
@ -13,9 +13,9 @@ export const eltOsagoRouter = router({
|
||||
eltOsago: protectedProcedure
|
||||
.input(EltInputSchema)
|
||||
.output(EltOutputSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
try {
|
||||
const apolloClient = initializeApollo();
|
||||
const apolloClient = initializeApollo(null, ctx.headers);
|
||||
const store = new RootStore();
|
||||
store.$calculation.$values.hydrate(input.calculation.values);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user