shurcooL/graphql

Support uuid type

KeisukeYamashita opened this issue · 1 comments

What

I want to use the Hasura GraphQL API.

query getTenantDetails {
  tenant_by_pk(id: $id) {
    id
    slug
    project {
      id
      endpoint
    }
  }
}

I defined the struct below and run with these script.

var GetTenantDetails struct {
	TenantByPK struct {
		//ID     graphql.ID
		Cloud  graphql.String
		Region graphql.String
	} `graphql:"tenant_by_pk(id: $id)"`
}

q := GetTenantDetails
vars := map[string]interface{}{
		"id": graphql.ID("my-id"),
	}

if err := client.Query(ctx, &q, vars); err != nil {
	log.Fatal(err)
}

But I get this weird error.

Error: variable id of type ID! is used in position expecting uuid!

How can I use uuid? I read the GoDoc but I couldn't find any types for UUID.
Thanks in advance.

robx commented

With the way the library determines types, I believe the following works:

type uuid string
vars := map[string]interface{}{
    "id": uuid("my-id"),
}

(uuid here should be literally the type that's used in the API)