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

Query Interfaces and unions #21

Closed
ereyes01 opened this Issue Oct 6, 2017 · 2 comments

Comments

2 participants
@ereyes01

ereyes01 commented Oct 6, 2017

Thanks for taking a crack at the client library...

How would you query a specific type when the schema specifies an interface or union as the return type?

For instance, say I try the following query to github:

query {
  search(first: 100, type: ISSUE, query: \"user:ereyes01 repo:firebase label:enhancement state:open\") {
    nodes {
      ... on Issue {
        number
      }
    }
  }
}

The search query returns a SearchResultItem, and in this case, I just want the issues. Is there a way using your library to specify the .. on Issue part of the query above?

@dmitshur dmitshur added the question label Oct 6, 2017

@dmitshur

This comment has been minimized.

Show comment
Hide comment
@dmitshur

dmitshur Oct 6, 2017

Member

Hi, yes, GraphQL inline fragments and unions are supported (see #10 for more information), but not documented in README yet. I plan to do that, and tracking it in shurcooL/graphql#3 issue.

The GraphQL query you posted can be expressed something like this:

var query struct {
	Search struct {
		Nodes []struct {
			Issue struct {
				Number int
			} `graphql:"... on Issue"`
		}
	} `graphql:"search(first: 100, type: ISSUE, query: $searchQuery)"`
}
Member

dmitshur commented Oct 6, 2017

Hi, yes, GraphQL inline fragments and unions are supported (see #10 for more information), but not documented in README yet. I plan to do that, and tracking it in shurcooL/graphql#3 issue.

The GraphQL query you posted can be expressed something like this:

var query struct {
	Search struct {
		Nodes []struct {
			Issue struct {
				Number int
			} `graphql:"... on Issue"`
		}
	} `graphql:"search(first: 100, type: ISSUE, query: $searchQuery)"`
}
@ereyes01

This comment has been minimized.

Show comment
Hide comment
@ereyes01

ereyes01 Oct 6, 2017

Awesome, and works great. Thanks!

ereyes01 commented Oct 6, 2017

Awesome, and works great. Thanks!

@ereyes01 ereyes01 closed this Oct 6, 2017

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