-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Default Field for type #459
Comments
Hey @BLamy, you can use a query fragment to avoid the repetition. Here's a good tutorial on fragments. As for the exact behavior you're asking about, GraphQL queries must specify selections down to scalar fields. In your example schema, the type underlying val1/val2 is an intermediate node, so you cannot have it as the terminating field in the selection. If you would like share more about your use case, I might be able to offer more suggestions. |
@robzhu Most users don't really need to know about the metadata embedded in each field (some might even be confused by it). However, I really feel I would be doing an injustice providing an API which doesn't expose access to it for more advanced users. It's not the end of the world if I need to tell them to always put |
I think you can easily do this yourself by writing a query visitor that uses the schema to add fields where necessary. I think it would be a huge step back for GraphQL if it wasn't required to list all of the fields you want, since that's one of the primary benefits of the platform especially for building tools and client libraries. |
I can think of some hacks. Make a parallel tree so that you have two root nodes. One which has children and it's fields return {value} implicitly and the other node that provides access to the "advanced" information. You could also add an additional field to each node for each field that has a {value} e.g. val1Value. One could argue that doing this would mess with the tree structure though. Ideal solution IMO is to define schema based on user/role. it would require you to add a user/role based check when defining the value resolver for these fields and make it so that field implicitly returns the value for non-technical roles. |
@BLamy |
@asiandrummer That is actually exactly what I was looking for. I just needed to add a value case like these special ones: |
* Allow interfaces to have no implementors Reverts #1277, and implements spec removal from #459. While it's an open question whether this validation is good, we need to provide an upgrade path for schemas that currently do not satisfy this validation rule. * Update test to accept unimplemented interface
I'm unsure of whether this is supported but I couldn't find it anywhere. I have a use case where I am representing a tree of values which looks a little something like this
95% of the time I only care about getting the 'value' property. Unfortunately, My query most of the time look like this:
I would like to query like this and have it just get the .value property by default.
However, If the user wants to get more metadata for a variable they can as so
The text was updated successfully, but these errors were encountered: