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

better error message or different behavior when expecting slice of structs, but have single struct #46

Open
dmitshur opened this issue Sep 5, 2019 · 3 comments
Labels
API decision NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@dmitshur
Copy link
Member

dmitshur commented Sep 5, 2019

From #45 (comment):

this package should do something better in this situation. Either the error message needs to be improved, or maybe it could unmarshal just the first book and drop the rest.

See issue #45 for more context.

/cc @starjasmine

@dmitshur dmitshur added API decision NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 5, 2019
@dmitshur
Copy link
Member Author

dmitshur commented Jan 4, 2020

A related problem happened in shurcooL/githubv4#55.

The problem was that the query was Repo []struct {...} but should've been Repo struct {...}. The error was "struct field for "name" doesn't exist in any of 1 places to unmarshal".

In this case, it doesn't seem that an alternative behavior would be viable, so a more detailed and helpful error message would be better. Need to investigate whether it is viable.

@davidkarlsen
Copy link

Hmm, I have this query:

var query struct {
		Organization struct {
			SamlIdentityProvider struct {
				ExternalIdentities struct {
					PageInfo struct {
						hasNextPage githubv4.Boolean
						endCursor   githubv4.String
					} `graphql:"pageInfo"`
					Edges []struct {
						Node struct {
							SamlIdentity struct {
								NameId   githubv4.String
								Username githubv4.String
							} `graphql:"samlIdentity"`
							User struct {
								Login githubv4.String
							} `graphql:"user"`
						} `graphql:"node"`
					} `graphql:"edges"`
				} `graphql:"externalIdentities(first: $first, after: $after)"`
			} `graphql:"samlIdentityProvider"`
		} `graphql:"organization(login: $login)"`
	}

which should match the returned structure just fine, but still it won't work?

@davidkarlsen
Copy link

doh, amateur-hour, I hadn't exported them. Disregard my comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API decision NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Development

No branches or pull requests

2 participants