-
Notifications
You must be signed in to change notification settings - Fork 82
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
Don't use Viewer #1
Comments
Hello @leebyron, I'm really glad that you took your time for opening an issue! That's what I initially had in mind but that's the only workaround that I saw since I needed it to work with Relay 1, which doesn't seem to handle multiple fields on the |
We should probably go back and edit that workaround as its no longer what we would suggest doing. It's based on a strange internal Facebook-ism that were trying to get rid of. I'd hate for new non-Facebook projects to have to suffer from it. A better workaround that's less invasive is a field on the query type that returns itself. So:
That lets people using your API largely ignore the workaround, but for the rare case you're using relay and accessing multiple fields you can just wrap them in |
Yes please! I love this kind of workaround that works with Relay but still lets other people not have to deal with it. |
@leebyron before this issue I had no idea that |
@leebyron, this is OK workaround but you still can't have
So you need to create another "route" in Relay. Really looking forward to Relay 2. |
@maletor that query should work just fine with the workaround I suggested above. But yes, Relay still requires both a top level field called node and requires one top level field per route. We're hoping to drop those requirements in the future, but this work around at least patches over the issue for most cases by allowing multiple fields on the nested "query" field |
Is this also related to why my connection type at the top level of my schema doesn't work with For instance, I'm trying to create a mutation that adds a node to a connection but that connection itself has no parent node -- it's just a query on the top level. |
@leebyron 2 pull request to remove viewer from server and relay https://twitter.com/sseraphini/status/900775274387820544 https://github.com/entria/graphql-dataloader-boilerplate/pull/59 |
(I guess I could use the request header context with some express middleware, but was trying to handle everything in GraphQL-layer with resolvers) Nevermind! I see that I can still use external tools to set authentication headers for GraphiQL and then read request headers via context. In my case, I'm going to use |
Love this!!!
Just a suggestion to not put everything on a
Viewer
type, which is an antipattern in GraphQL servers, but instead to put all root access on theQuery
type.The text was updated successfully, but these errors were encountered: