-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add relay modern support #4458
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
add relay modern support #4458
Conversation
|
Deploy preview for hasura-docs ready! Built with commit 6cf3c97 |
|
I believe the Relay spec supports queries without the use of edges/connections/nodes, I believe it is only the cursor spec that requires them. To use example from the relay docs and Are both valid, although one obviously returns all and one turns the first only. Using the second way, I believe you could keep the way Hasura currently handles aggregations. and And this would be valid with Relay and work with Hasura's engine converts the to the database id in the standard way of using tablename_id. We have been using relay modern for 12+ months and do not use cursors, edges, connections or nodes. It would be great to see both ways of querying be supported with the Relay implementation. Please let us know when there is a working implementation, and we'll happy set it up and give it a try and provide any feedback. |
|
Review app for commit e0478d2 deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
** ../DML/Select/* modules refactor -> Brand new functions and types -> Refactor the Annotated internal AST with better names
|
Review app for commit 8e28ed3 deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
Resolve Conflicts: server/src-lib/Hasura/GraphQL/Execute.hs server/src-lib/Hasura/GraphQL/Explain.hs server/src-lib/Hasura/GraphQL/Resolve.hs server/src-lib/Hasura/GraphQL/Resolve/Select.hs server/src-lib/Hasura/GraphQL/Resolve/Types.hs server/src-lib/Hasura/GraphQL/Schema.hs server/src-lib/Hasura/GraphQL/Transport/HTTP.hs server/src-lib/Hasura/RQL/DDL/Schema/Cache.hs server/src-lib/Hasura/RQL/DML/Select.hs server/src-lib/Hasura/RQL/DML/Select/Internal.hs server/src-lib/Hasura/Server/App.hs
Resolve Conflicts: server/cabal.project server/cabal.project.freeze server/src-lib/Hasura/GraphQL/Execute.hs server/src-lib/Hasura/GraphQL/Resolve/Introspect.hs server/src-lib/Hasura/GraphQL/Validate.hs
|
Review app for commit 71b5d05 deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
|
Review app for commit fb92eb7 deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
|
Review app for commit ff5d97b deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
|
@wawhal The relay api toggle status on console should be persisted to LS |
|
Review app for commit f1c07e2 deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
This comment has been minimized.
This comment has been minimized.
|
Review app for commit 97814f4 deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
|
Review app for commit ef8255f deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
| } | ||
|
|
||
| .graphiqlModeToggle { | ||
| margin-top: -5px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead decrease margin-top here: https://github.com/hasura/graphql-engine/blob/master/console/src/components/Common/Common.scss#L1264?
So that those two elements don't overlap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. Can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. A few points on negative margins:
- Layout is not clean — elements overlap
-
When composing a layout we should stick to make it as simple as possible
-
Negative margins may lead to inconsistent results in different browsers (might not be the case for us, tho)
Sometimes negative margins are needed and there's no other way around, but in this case, we can compose the elements by reducing the margin of one of them. That's why I put this comment.
This is not something super bad but the thing is they may be harmful, so it's good to avoid them when possible.
console/src/components/Services/ApiExplorer/ApiRequest/ApiRequest.js
Outdated
Show resolved
Hide resolved
console/src/components/Services/ApiExplorer/GraphiQLWrapper/GraphiQLWrapper.js
Outdated
Show resolved
Hide resolved
|
Does this PR support relay persist queries? |
|
@rakeshkky The spec gives priority to https://relay.dev/graphql/connections.htm#sel-FAJLJCDDAAHFDDFBGB_yN |
|
Review app https://hge-ci-pull-4458.herokuapp.com is deleted |
|
Review app for commit acca92c deployed to Heroku: https://hge-ci-pull-4458.herokuapp.com |
The global unique id is base64 encoding of the JSON object which contains the details of the table name itself and primary key column values. The Regarding I blindly followed the note and made a decision not to allow both arguments. Edit 1:- The |
|
@rakeshkky - I am must not be making myself clear. The issue is that the relationship ids are different to the item ids. In the database the ids look like However Hasura is returning is returned the base64 encoded table+id for the id, but not for the relationship id. From current hasura query result Now there is no way to match role_id: 4 to the role, because the ids are different. Hasura should be returning role_id as the base64 encoded table+id instead like this: This is how all other relay + sql implementations I have used work. |
|
@rakeshkky currently "normal" ids are used in URL like https://my.app/company/h3ol3ne. Here is short id "h3ol3ne" which exact row id in table "company". Now in Relay API mode ids not the same and match longer. Is there a right way to use previous ids? |
|
In a given table, the In the use case you mentioned: I think there's no point in having To avoid conflicts, you can customize the column name. If relay clients work with custom name for Please do open an issue on github, specifying your concerns on the relay as this PR got merged to master as that would be easier to track and discuss. 😃 |
You can make use of customize column name feature to rename the |
|
What happen with this task "Implement camelcase and singular/plural inflection"?. Even though it might not be explicitly in the graphql spec the camel case, is definitely a convention. In 1.3 beta for relay the connections cant be aliased like the table fields, also there is a mix of camel case and snake case, which makes it inconsistent. For my particular case, I'm considering hasura to replace an existing graphql api that is consumed by a relay client. The camel case is a big problem, since we would have to modify all the existing graphql queries and I want to do this with the least possible changes to the existing client code. |
|
In another note, I think the generated global IDs are too big. Just consider the request payloads and response data size increase just because of this small detail. Also consider that this IDs could be used in URLs (any client/app). The base64 encoded data has too much information for an identification string |
|
@rakeshkky - I have made an issue here #5035 #5036 #5037 @jmsegrev - I've also added an issue for your suggestion |
|
Huge thanks for adding relay support! I'm testing it right now, it works pretty well but I find something weird, |
|
@tsnobip Just speculation from my side, but this is sometimes an effect of how permissions are implemented. Ie "fetch all rows, check permission for each node". I dunno if that's the case here though, but just to provide some context on when |
* validation support for unions and interfaces * refactor SQL generation logic for improved readability * '/v1/relay' endpoint for relay schema * implement 'Node' interface and top level 'node' field resolver * add relay toggle on graphiql * fix explain api response & index plan id with query type * add hasura mutations to relay * add relay pytests * update CHANGELOG.md Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com> Co-authored-by: Rishichandra Wawhal <rishi@hasura.io> Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
|
@rakeshkky please how the id is generated?
Can you show the JSON object format, please? I would like to generate the id, but I need the JSON fields, for example: {
"table_name": "my_table",
"pk": "4ddd3e6c-7528-41d4-a052-84e57931b199"
}What names are used in the I need to generate the ids while #5658 is not fixed because I'm using a custom function in the regular endpoint, that should contain the relay id of the record. |
|
@tirumaraiselvan thanks for the response, I've submitted a PR to add an example of how to get the relay id in the graphql endpoint #6054 |
* validation support for unions and interfaces * refactor SQL generation logic for improved readability * '/v1/relay' endpoint for relay schema * implement 'Node' interface and top level 'node' field resolver * add relay toggle on graphiql * fix explain api response & index plan id with query type * add hasura mutations to relay * add relay pytests * update CHANGELOG.md Co-authored-by: rakeshkky <12475069+rakeshkky@users.noreply.github.com> Co-authored-by: Rishichandra Wawhal <rishi@hasura.io> Co-authored-by: Rikin Kachhia <54616969+rikinsk@users.noreply.github.com>
We've started work on adding a Relay (Modern) interface to graphql-engine (finally!). We've put together this PR so that you can track progress and provide feedback as we work.
Our main challenges with the connection spec / cursors, that we’ve largely resolved:
Todos:
/v1/graphqlto/v1/relayendpoint.One of the key open questions as we land this support is:
Should we add it as part of the
Connectionobject in addition topageInfoandedgesfields? If so, do Relay clients support such additional fields?