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

We should not allow for empty fragments fields should be selected #3

Open
mikkoh opened this issue Oct 18, 2016 · 3 comments
Open

We should not allow for empty fragments fields should be selected #3

mikkoh opened this issue Oct 18, 2016 · 3 comments

Comments

@mikkoh
Copy link
Member

mikkoh commented Oct 18, 2016

I don't think we should allow users to create empty fragments for instance in this case:

const graph = new Graph('Shop');

assert.deepEqual(splitQuery(graph.toQuery()), splitQuery('fragment on Shop { }'));

We should probably throw an Error when the user calls graph.toQuery(). Basically be pre-emptive on helping the user before they get errors back from the API.

@mikkoh
Copy link
Member Author

mikkoh commented Oct 18, 2016

I've been thinking about this more and maybe the query should actually just return a blank string and log a warning that they're wanting to query Shop but are not selecting any fields.

I'm just thinking from a UI perspective. If a parent component sais something like:
"I am a Shop component therefore we'll need to query on Shop"
But then child UI components don't actually query any of the fields.

Thoughts @minasmart @jamesmacaulay?

@minasmart
Copy link
Contributor

I think we should error out if they don't add selections to a field that has a kind of OBJECT. Any such query would fail, since all queries against an OBJECT kind require selections. I think I'd error at the point when addField is called and no selections are added.

@minasmart
Copy link
Contributor

Also, my opinion is the sane regardless of wether this is a fragment or a field. We know the kind either way.

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

No branches or pull requests

2 participants