hasura / go-graphql-client

Package graphql provides a GraphQL client implementation.
MIT License
395 stars 91 forks source link

field 'update_schema_event' not found in type: 'query_root', #115

Closed MohamedKHALILRouissi closed 9 months ago

MohamedKHALILRouissi commented 9 months ago

am doing this query and am always getting error Message: field 'update_schema_event' not found in type: 'query_root', Locations: [], Extensions: map[code:validation-failed path:$.selectionSet.update_schema_event] when i do it in hasura console it works

code

func UpdateSchemaResult(id int, result string) error {
    client := startgraphqlconnection()

    var mutation struct {
        update_schema_event struct {
            Affected_Rows int `json:"affected_rows"`
        } `graphql:"update_schema_event(where: { id: { _eq: $id }}, _set: { result_id: $result })"`
    }
    variables := map[string]interface{}{
        "id":     id,
        "result": result,
    }

    err := client.Query(context.Background(), &mutation, variables)
    if err != nil {
        fmt.Println("error", err)
        return err
    }
    return nil
}

i also tried with this method but the same result

    var mutation struct {
        Updateschemaevent struct {
            AffectedRows int `graphql:"affected_rows"`
        } `graphql:"update_schema_event(where: $where, _set: $set)"`
    }
    variables := map[string]interface{}{
        "where": schema_event_bool_exp{
            "id": map[string]interface{}{
                "_eq": id,
            },
        },
        "set": schema_event_set_input{
            "result_id": result,
        },
    }

thanks for help

MohamedKHALILRouissi commented 9 months ago

image

hgiasac commented 9 months ago

The console uses an admin secret with full access to the GraphQL schema. You should check if the client also set x-hasura-admin-secret or Authorization header if the client uses JWT/custom auth.

If you use another role for the client you should check if that role has the update permission to schema_event table

MohamedKHALILRouissi commented 9 months ago

i already defined that , i have another query that works fine , and am using the root user have all permissions