v0.3.0
Pre-release
Pre-release
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
}