Skip to content

v0.3.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@imperfect-fourth imperfect-fourth released this 13 Jun 09:12
· 8 commits to main since this release
bfddcea

Introduce query variables for scalar types and json, jsonb types in update query(can only be used in Set for now)

type User struct {
    ID   int    `json:"id"`
    Name string `json:"name"`
    Age  *int   `json:"age"` //nullable type
}

...

age := 10
Update[User]().Where(Eq(User_IDField(1)).Set(
    User_NameVar("abcd"),
    User_AgeVar(&age)
).Select(User_Name).Exec(client)

generated query:

mutation update_user($User_Name: String!, $User_Age: Int) {
  update_user(where: {id: {_eq: 1}, _set: {name: $UserName}) {
    name
  }
}

Note how $User_Name is a required String! var, and $User_Name is a nullable Int var. This is inferred from the User struct definition(string, *int, etc)

generated variables:

{
  "User_Name": "abcd",
  "User_Age": 10
}