Skip to content

nextjs release breaks server component use of Apollo query latest release #10974

@kimutaiRop

Description

@kimutaiRop

from nextjs version 13.4.6-canary.2 this package breaks when trying to use in server component
getting error

ReactServerComponentsError:

You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.

   ,-[/home/user/Desktop/web-test/test-frontend/node_modules/.pnpm/@apollo+client@3.8.0-alpha.15_graphql-ws@5.13.1_graphql@16.6.0_react-dom@18.2.0_react@18.2.0/node_modules/@apollo/client/react/hooks/useBackgroundQuery.js:1:1]
 1 | import { useEffect, useState, useMemo, useCallback } from 'react';
 
 The error was caused by importing '@apollo/client/index.js' in './src/graphql/home/queries.ts'.

this was working just fine before the release and then the update broke it, am thinking maybe it is caused by exporting server usable apis and only client usable in the same files

I dont know but I kinda think the issue could be somewhere around there this is caused by importing gql used to construct the query

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions