Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query type issue in 3.12 #12212

Closed
sebakerckhof opened this issue Dec 12, 2024 · 6 comments · Fixed by #12214
Closed

Query type issue in 3.12 #12212

sebakerckhof opened this issue Dec 12, 2024 · 6 comments · Fixed by #12214
Labels

Comments

@sebakerckhof
Copy link
Contributor

Issue Description

After upgrading to 3.12 I get a typescript issue on introspection queries:

import { IntrospectionQuery, buildClientSchema, getIntrospectionQuery } from 'graphql';
import { ApolloClient, gql, ApolloLink, HttpLink, InMemoryCache } from '@apollo/client';

  const client = new ApolloClient({
    link: ApolloLink.from([new HttpLink({ uri: '...' })]),
    cache: new InMemoryCache(),
  });
  const query = gql`
    ${getIntrospectionQuery()}
  `;
  const { data } = await client.query<IntrospectionQuery>({ query });

now throws a TS error: Type instantiation is excessively deep and possibly infinite.ts(2589)

Link to Reproduction

https://codesandbox.io/p/devbox/festive-butterfly-qvg335?workspaceId=ws_T9zoVXW5YchVwWgD3deZYC

Reproduction Steps

No response

@apollo/client version

3.12.2

@phryneas
Copy link
Member

Hi Seba,
thank you for the report!

Unfortunately, that DevBox is private - could you please set it to public?

@sebakerckhof
Copy link
Contributor Author

oops, it's public now. It's basically just the same snippet as above in the index.ts file displaying the issue.

@phryneas
Copy link
Member

Ah, I see, that IntrospectionQuery type is self-recursive, like

interface Rec {
  foo: Rec
 } 

(IntrospectionObjectType references IntrospectionField which references IntrospectionOutputTypeRef which references IntrospectionOutputType which references IntrospectionObjectType again).

This will take some tinkering.

What you can do in the meantime, as some kind of dirty workaround is

await client.query<IntrospectionObjectType & { __masked?: true }>({ query });

@phryneas
Copy link
Member

I believe #12214 should fix this - could you please try the PR build and report back?

npm i https://pkg.pr.new/@apollo/client@12214

Copy link
Contributor

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.

@sebakerckhof
Copy link
Contributor Author

Can confirm it's fixed, thanks for the fast solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants