Directives with ":" in value generate incorrect go tags
- Langage dominant
- Go
- Étoiles
- 10.8k
- Forks
- 1.3k
- Merge moyen
- 2 j 36 min
- PR mergées (30 j)
- 26
Description
### What happened?
I declare a directive for custom go tags (in `schema.directives.gql`):
```
directive @goTag(
key: String!
value: String
) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
```
Then I use it the following way :
```
type Value {
value: Float!
unit: String!
}
type Order {
name: String! @goTag(key: "gorm", value: "primaryKey")
amount: Value! @goTag(key: "gorm", value: "embedded;embeddedPrefix:dissolutionAmount_")
submitterRef String!
submitter: Person! @goTag(key: "gorm", value: "foreignKey: SubmitterRef")
}
```
Then I run code generation: `go run github.com/99designs/gqlgen generate` and the resulting code contains gorm tags that cut out text after colon:
```
type Order struct {
Name string `json:"name" gorm:"primaryKey"` // <--- this is correct
Amount Value `json:"amount" gorm:"embedded;embeddedPrefix` // INCORRECT - everything after "embeddedPrefix" is truncated: ":dissolutionAmount_" is missing, including trailing double quote
SubmitterRef string. `json:"submitterRef"`
Submitter Person `json:"submitter" gorm:"foreignKey` // INCORRECT - value in gorm tag is truncated, ": SubmitterRef" is missing
}
```
### What did you expect?
I expect the generated go code to include the correct gorm tags in the respective fields:
```
type Order struct {
Name string `json:"name" gorm:"primaryKey"`
Amount Value `json:"amount" gorm:"embedded;embeddedPrefix:dissolutionAmount_"`
SubmitterRef string. `json:"submitterRef"`
Submitter Person `json:"submitter" gorm:"foreignKey:SubmitterRef"`
}
```
### Minimal graphql.schema and models to reproduce
### versions
- `go run github.com/99designs/gqlgen version`? v0.17.34
- `go version`? v1.21.0
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.