Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support uuid type #61

Open
KeisukeYamashita opened this issue Oct 2, 2020 · 1 comment
Open

Support uuid type #61

KeisukeYamashita opened this issue Oct 2, 2020 · 1 comment

Comments

@KeisukeYamashita
Copy link

KeisukeYamashita commented Oct 2, 2020

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
Copy link

robx commented Feb 9, 2021

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants