Tag: next.js
-
Error handling in Apollo Server GraphQL not redirecting to login page
0 // Error handling code in Apollo Client onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) { graphQLErrors.forEach(({ message, locations, path }) => { console.log( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` ); if (message.includes("not authenticated")) { if (typeof window === "undefined") { ctx.res?.writeHead(302, { Location: "/login" }); ctx.res?.end(); } else { useRouter().replace("/login"); }…
-
Error: “An issue happened while applying the transaction”. Grafbase problem on production
0 When I try to create a server I get an error. The server is created but without any relation to the user. Everything works fine locally. The error only appears in production. Here’s my schemas: schema @auth( providers: [ { type: jwt, issuer: "nextauth", secret: "{{ env.NEXTAUTH_SECRET }}" } ] rules: [{ allow: private…
-
why `refetch` in “useLazyQuery” of Apollo-client, doesn’t causing component re-rendering or update `data` in next js?
0 I created a react-hook for useLazyQuery. export const useCustomQuery = ({ query, variables, hasAuth, hasVar }: HookOptions) => { let options = {}; if (Boolean(hasVar) && Boolean(variables)) { options = { …options, variables, }; } if (Boolean(hasAuth)) { let token = ""; if (typeof window !== "undefined") { token = localStorage.getItem("accessToken") || ""; }…
-
Update Shopify product price using StorefrontAPI
0 I want to compute some conditions based on the user’s choices in the front end and update the product price of that variant in Shopify via a GraphQl mutation. Is it possible with the Storefront API setup? FYI I’m using Nexjs Commerce to set up my store. I don’t want to include Admin Api…
-
String cannot represent a non string value [Apollo client and nextjs]
0 I am working on a project which uses apollo client and nextjs on the frontend and apollo server with nodejs on the backend In nextJs when i am using getServerSideProps , i am passing a string variable "orderBy" with the query export async function getServerSideProps(context: GetServerSidePropsContext) { const { query } = context const…
-
Limit API Calls in nextJS to Hygraph
0 I’m building nextJS webApp that accesses hygraph for data management via API calls(GraphQL). Hygraph limits the free plan to 1M API calls per project per month. Each page on the webapp requests data independently through API with useeffect. For example: const Team = () => { let router = useRouter(); const [profile, setProfile] =…
-
Next.js getStaticProps error in production. GraphQL Apollo client not rendering variable, instead getting error: Type error: No value exists in scope
0 My code seems to work in development but when I step away from the local environment, i get an error: Type error: No value exists in scope for the shorthand property ‘currentTime’. Either declare one or provide an initializer. I am using Next.js and Typescript. I am not sure if this is a type…
-
Getting posts undefined in headless wp with graphQl Next.js
0 The graphQL query is working https://trialtest1.local/graphql?query={%20posts%20{%20nodes%20{%20slug%20title%20}%20}} But when I ask for posts in next.js it shows undefined. Can anyone see what Im doing wrong? import Link from ‘next/link’ export default function Home( {posts}){ console.log({posts}) return( <div> <h1>Hello From The Home Page!</h1> { posts?.nodes?.map(post => { return( <ul key={post.slug}> <li> <Link href={`/posts/${post.slug}`}>{post.title}</Link> </li> </ul> )…
-
GraphQL Apollo Server Introspection error
0 I’ve been getting this error when I run npx diagnose-endpoint for my apollo client. **Diagnosing https://localhost:3000/api/graphql ⚠️ Introspection query could not parse "POST body missing, invalid Content-Type, or JSON object has no keys." As valid json. Here is the error: SyntaxError: Unexpected token "P", "POST body "… is not valid JSON ** I’m setting…
-
NextJS 13.5 causes graphql schema errors
0 After updating to NextJS 13.5 I started seeing these errors when deployed on Vercel (but works fine locally): Error: Schema must contain uniquely named types but contains multiple types named "h". at new GraphQLSchema (/var/task/node_modules/.pnpm/[email protected]/node_modules/graphql/type/schema.js:219:15) My init code is pretty straightforward in the serverless function: const schema = buildSchemaSync({ authChecker: UserAuthority, resolvers: […] });…