dotansimha / dotansimha/graphql-code-generator-community

[urql] should respect omitOperationSuffix and typesPrefix options

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

Description

**Describe the bug**
I am used to prefixing my operations with `Q/M/S/F` so I opted enabled option `omitOperationSuffix`. Unfortunately, the urql plugin doesn't consider that and uses wrong type names., Also for a reason, I like to prefix types with `T` which is ignored by plugin as well.

https://github.com/dotansimha/graphql-code-generator/blob/db1db14ad43bdd876b4eab053d41b074b872359c/packages/plugins/typescript/urql/src/visitor.ts#L87

**To Reproduce**
Steps to reproduce the behavior:

I tried to reproduce in codesandbox, but it's giving me weird errors: https://codesandbox.io/s/affectionate-montalcini-zcpsv?file=/codegen.yml

1. My GraphQL schema:

```graphql
type Query {
user(id: ID!): User!
}

type User {
id: ID!
email: String!
}
```

2. My GraphQL operations:

```graphql
# Put your operations here
query user {
user(id: 1) {
id
email
}
}
```

3. My `codegen.yml` config file:

```yml
# Put your YML here
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-operations
- typescript-urql
config:
typesPrefix: T
omitOperationSuffix: true
withComponent: false
withHooks: true
```

**Expected behavior**

The emitted types should not use operation type suffix when `omitOperationSuffix` is enabled. And `typesPrefix` should be respected.

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.