0no-co / gql.tada

🪄 Magical GraphQL query engine for TypeScript
https://gql-tada.0no.co
MIT License
2.44k stars 34 forks source link

Incorrect types #333

Closed SPAHI4 closed 1 week ago

SPAHI4 commented 1 week ago

Describe the bug

Types are not working

I have almost the same setup in 2 places, but

  1. Legacy project, query object doesn't have all properties like kind
image image
import { useSuspenseQuery } from '@apollo/client';
import { graphql } from 'gql.tada';

const query = graphql(`
  query PostsQuery {
    allPosts {
      nodes {
        id
      }
    }
  }
`);

const Test = () => {
  const { data } = useSuspenseQuery(query); // data = unknown
};
  1. Project from scratch - It does
image

In the first case, I have already setup a huge project. What could possibly be wrong? graphql package version?

tsconfig:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": { "@/*": ["./*"] },
    "target": "ES2020",
    "lib": ["dom", "dom.iterable", "esnext"],
    "skipLibCheck": true,
    "strict": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "noEmit": true,
    "jsx": "react-jsx",
    "sourceMap": true,
    "plugins": [
      {
        "name": "@0no-co/graphqlsp",
        "schema": "./schema2.graphql",
        "tadaOutputLocation": "./src/graphql-env.d.ts"
      }
    ]
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

Reproduction

No response

gql.tada version

    "@0no-co/graphqlsp": "^1.12.10",

    "typescript": "^5.5.3",

    "gql.tada": "^1.8.0",

    "@apollo/client": "^3.10.8",

I forced yarn resolutions to match graphql versions on both projects, no result

  "resolutions": {
    "graphql": "15.9.0"
  }

gql.tada doctor no issues found

Validations

SPAHI4 commented 1 week ago

I've found the issue, I deleted the line below:

 "baseUrl": "./src",