dotansimha / dotansimha/graphql-code-generator

It is incorrect that using Parameter to get the type of `graphql` method in gql.ts.

Open
#8,762 1 comment 0 reactions 0 assignees View on GitHub
stage/4-pull-request
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/client-preset

### Describe the bug

using graphql code generator to generate gql.ts like below:

```ts
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "\n query queryUser($id: Int!) {\n user(id: $id) {\n id\n username\n password\n }\n }\n "): (typeof documents)["\n query queryUser($id: Int!) {\n user(id: $id) {\n id\n username\n password\n }\n }\n "];

/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*
*
* @example
* ```ts
* const query = gql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
* ```
*
* The query argument is unknown!
* Please regenerate the types.
**/
export function graphql(source: string): unknown;
```

And I want to get the type of the `source` param like below:
```ts
Parameters[0]
```
the result is ` string ` but not the regenerated type.

### Your Example Website or App

https://stackblitz.com/edit/github-si33xs?file=codegen.ts,package.json,test.ts,graphql%2Fgql.ts

### Steps to Reproduce the Bug or Issue

1. go to `test.ts`
2. look the type of `query`

### Expected behavior

I want return the regenerated type when using Parameter to get this param type of `graphql` method.

### Screenshots or Videos

_No response_

### Platform

- NodeJS: [16.15.0]
- `graphql` version: [e.g. 16.3.0]
- `@graphql-codegen/cli` version(s): [2.13.12]
- `@graphql-codegen/client-preset` version(s): [1.1.5]

### Codegen Config File

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.