You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// src/providers/apollo-provider.tsx"use client";import{HttpLink,ApolloLink,concat,split}from"@apollo/client";import{ApolloNextAppProvider,ApolloClient,InMemoryCache,}from"@apollo/experimental-nextjs-app-support";importCookiesfrom'js-cookie';import{GraphQLWsLink}from'@apollo/client/link/subscriptions';import{createClient}from'graphql-ws';import{getMainDefinition}from"@apollo/client/utilities";// have a function to create a client for youfunctionmakeClient(){consthttpLink=newHttpLink({uri: process.env.NEXT_PUBLIC_GRAPHQL_API_URL,fetchOptions: {cache: "no-store"},});constwsLink=newGraphQLWsLink(createClient({url: process.env.NEXT_PUBLIC_GRAPHQL_API_URL_WSS,connectionParams: ()=>{consttoken=Cookies.get('authToken');return{authToken: token}},disablePong: false,retryAttempts: 3,keepAlive: 60*1000,}));// The split function takes three parameters://// * A function that's called for each operation to execute// * The Link to use for an operation if the function returns a "truthy" value// * The Link to use for an operation if the function returns a "falsy" valueconstsplitLink=split(({ query })=>{constdefinition=getMainDefinition(query);return(definition.kind==='OperationDefinition'&&definition.operation==='subscription');},wsLink,httpLink,);constauthMiddleware=newApolloLink((operation,forward)=>{consttoken=Cookies.get('authToken');operation.setContext({headers: {Authorization: token ? `Bearer ${token}` : "",},});returnforward(operation);});// use the `ApolloClient` from "@apollo/experimental-nextjs-app-support"returnnewApolloClient({// use the `InMemoryCache` from "@apollo/experimental-nextjs-app-support"cache: newInMemoryCache(),link: concat(authMiddleware,splitLink),});}// you need to create a component to wrap your app inexportfunctionApolloWrapper({ children }: React.PropsWithChildren){return(<ApolloNextAppProvidermakeClient={makeClient}>{children}</ApolloNextAppProvider>);}
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ApolloError: Query failed upstream.
at new t (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:3:40255)
at /home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:3:167371
at i (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:3:135108)
at /home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:3:135023
at new Promise (<anonymous>)
at Object.then (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:3:134990)
at Object.error (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:3:135118)
at g (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:191:5580)
at b (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:191:6081)
at t.error (/home/sandro/Desktop/projects/shopping-cart-manager/.next/server/chunks/686.js:191:6634)
Export encountered an error on /page: /, exiting the build.
⨯ Next.js build worker exited with code: 1 and signal: null
The text was updated successfully, but these errors were encountered:
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
Code
problem
When I run
next build
I get an error:The text was updated successfully, but these errors were encountered: