dotansimha / dotansimha/graphql-code-generator
Unused base types from operations.ts file in generated hooks [typescript-urql + import-types preset]
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Description**
when using typescript-urql plugin along with import-types preset the generated hooks are not using the base types from the generated operations.ts file
1. My GraphQL schema:
```graphql
type Mutation {
createUser(email: String!, name: String!): User!
}
type Post {
author: User
authorId: Int!
content: String
id: Int!
published: Boolean!
title: String!
}
type Query {
getAllPosts: [Post!]!
getAllUsers: [User!]!
getUserByEmail(email: String): User!
}
type User {
email: String!
id: Int!
name: String!
posts: [Post!]
}
```
2. My GraphQL operations:
```graphql
query getAllUsers {
getAllUsers {
id
name
email
posts {
title
content
author {
name
}
}
}
}
```
3. My `codegen.yml` config file:
```yml
overwrite: true
schema: 'http://localhost:3000/api'
hooks:
afterAllFileWrite:
- eslint --fix
generates:
generated/schemas.ts:
documents: 'graphql/**/*.graphql'
plugins:
- typescript
generated/operations.ts:
documents: 'graphql/**/*.graphql'
preset: import-types
presetConfig:
typesPath: ./schemas
importTypesNamespace: SchemaTypes
plugins:
- typescript-operations
generated/hooks.ts:
documents: 'graphql/**/*.graphql'
preset: import-types
presetConfig:
typesPath: ./operations
importTypesNamespace: OperationTypes
plugins:
- typescript-urql
config:
withHOC: false
withComponent: false
withHooks: true
```
**Expected behavior**
the generated hooks.ts file must use the imported base types from the operations.ts file. the types from the schema.ts file is used in the operations.ts file but the same is not reflecting in the hooks.ts file
**Environment:**
- OS: mac
- Node: v10.13.0
- `@graphql-codegen/cli: 1.17.6`
- `@graphql-codegen/typescript-urql: 1.17.6`
**Additional context**


Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.