dotansimha / dotansimha/graphql-code-generator-community
Type-graphql doesn't support a scalar as input argument type
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
**Describe the bug**
When a mutation argument type contains a scalar property the generated code fails to compile. The scalar is wrapped with either a FixFixture<> or Maybe<> with the error message "Cannot find name ''"
**To Reproduce**
1. Create a schema that contains a mutation with with null or non-null argument scalar property (see below)
2. Generates the following code for the argument.
@TypeGraphQL.ArgsType()
export class MutationRemoveUserArgs {
@TypeGraphQL.Field(type => CustomID)
id!: FixDecorator;
};
Error message: "Cannot find name 'CustomID"
1. My GraphQL schema:
```graphql
scalar CustomID
interface Node {
id: CustomID!
}
type User implements Node {
id: CustomID!
username: String!
email: String!
}
type Mutation {
removeUser(id: CustomID!): RemoveByIdEmployeePayload
}
type RemoveByIdEmployeePayload {
id: CustomID!
}
```
2. My GraphQL operations:
```graphql
None
```
3. My `codegen.yml` config file:
```yml
schema: schema.graphql
config:
scalars:
CustomID: String
generates:
./generatedTypeGraphQL.ts:
plugins:
- typescript-type-graphql
```
**Expected behavior**
Expecting the argument class to be:
@TypeGraphQL.ArgsType()
export class MutationRemoveUserArgs {
@TypeGraphQL.Field(type => String)
id!: FixDecorator;
};
**Environment:**
- OS: Mac OS
- `@graphql-codegen/...`:
"@graphql-codegen/cli": "^1.21.3",
"@graphql-codegen/typescript-type-graphql": "^1.18.3"
- NodeJS:v15.3.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked sandbox and run `yarn generate` using the shown schema.graphql and codegen.yml. Inspect generatedTypeGraphQL.ts and the typescript-type-graphql plugin's handling of scalar mutation arguments. Done means the generated argument class compiles and matches the expected CustomID mapping without an unresolved scalar name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100