dotansimha / dotansimha/graphql-code-generator-community

[typescript-react-query] using query key as a generated document.

Open
#188 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

I have two type of MyQuery describe at diffrence folder like,

```graphql
query MyQuery {
myQuery {
id
}
}
```

```graphql
query MyQuery {
myQuery {
id
name
}
}
```

but it generated like this. query key duplicated.

```typescript
export const useMykemiQuery = (...) =>
useQuery(
['MyQuery', variables], // <- here. query keys are duplicated.
...);
```

these two queries are diffrent reponse but share same query key.

there are some solution to fix this, like make coding convention or something.

but i suggest using query key as a generated document. like

```typescript
export const MyQueryDocument = '...';

export const useMykemiQuery = (...) =>
useQuery(
[MyQueryDocument, variables], // <- there are no duplicated anymore.
...);
```

if keys are duplicated sometimes, it has no problem because tow queries are same response.

if already have this option, please let me know. or some other solution.

thank you. 🙂

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.