GqlGen incorrectly generates directives that have colon character in value field

GqlGen incorrectly generates directives that have colon character in value field


0

I use https://github.com/99designs/gqlgen for generating golang code from graphql schema. I need to be able to add gorm tags to the resulting golang types. For that, 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 in a graphql schema file:

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 ":" character:

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
}

Share
Improve this question


Load 4 more related questions


Show fewer related questions

0

Reset to default



Leave a Reply

Your email address will not be published. Required fields are marked *