My schema consists partly of this:
type User @secret(field: "pass") {
email: String! @id @search(by:[term])
name: String! @search(by:[term])
description: String
status: String! @search(by:[hash])
workPlace: String @search(by: [term])
When I ran a mutation using this code
type user struct {
Email string `json:"User.email"`
Password string `json:"User.pass"`
Name string `json:"User.name"`
Status string `json:"User.status"`
}
func (c *Client) CreateUser(ctx context.Context, email, password, name string) error {
user := user{
Email: email,
Password: password,
Name: name,
Status: "Active",
}
d, err := json.Marshal(&user)
if err != nil {
return fmt.Errorf("could not marshal user %s: %v", string(d), err)
}
log.Printf("mutation: %s", string(d))
txn := c.dgClient.NewTxn()
_, err = txn.Mutate(context.Background(), &api.Mutation{SetJson: d, CommitNow: true})
if err != nil {
return fmt.Errorf("Could not mutate user %+v: %v", string(d), err)
}
return nil
}
No error is returned by a mutation but the database does not have any user.
I have tried to put like User.mail and it correctly tells me that the attribute mail does not exist on type user, but with this mutation, everything looks fine but somehow, data is not being saved.