hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.18k stars 2.77k forks source link

remote schema to database joins #5801

Open John0x opened 4 years ago

John0x commented 4 years ago

Hey, I expected the remote joins to support responses as well and not just arguments of an query. Will this be supported in the future?

One of my remote schemas responses contains the userId, which I would like to join with the "user" table, so that on the response someone could also query the user object.

esseswann commented 4 years ago

This might cause a circular reference. It's explained here https://github.com/hasura/graphql-engine/issues/2494#issuecomment-675498002

tirumaraiselvan commented 4 years ago

This is remote schema to db join which is part of the roadmap and will be possible soon (Action relationships are kind of similar btw).

John0x commented 4 years ago

Great, thank you :) Is there a rough a ETA on when that feature will arrive?

seanaye commented 4 years ago

Just want to clarify that this is a sort of 'right join' where a remote schema can return a key then hasura will look up that key and return the data? The opposite of current remote join where hasura sends key and remote schema resolves, this would allow remote schema to pass key back to hasura and hasura would resolve? Beacuse that would be amazing

karibertils commented 4 years ago

Looking forward to this feature

JCMais commented 3 years ago

I was trying to do exactly that but found out it's not supported yet. This is an important feature for anyone using remote schemas, especially so if using apollo client in the frontend.

Use case:

Is there any update related to when this feature is going to become available? Or if it's planned at all. Anything the community can do to help with the development of this?

tirumaraiselvan commented 3 years ago

Is there any update related to when this feature is going to become available? Or if it's planned at all.

This is definitely planned and high up in our priority.

JCMais commented 3 years ago

@tirumaraiselvan are there any updates related to this? Any chances for this to be included with v2?

jgoux commented 3 years ago

@JCMais According to @coco98 it should be released by end of May. 🎊

andreasgangso commented 3 years ago

Any status on this @0x777?

jgoux commented 3 years ago

It's me again, I'm back from the future.

Apparently it's the last remaining feature of the quarter and it should be ready for the end of September (@coco98 gave me the ETA earlier this week). 🤞

Hopefully I won't be wrong this time, it's my most needed feature. 😅

WonderPanda commented 3 years ago

I was trying to do exactly that but found out it's not supported yet. This is an important feature for anyone using remote schemas, especially so if using apollo client in the frontend.

Use case:

  • Remote schema has an UpdateUser mutation that returns the updated_user_id: String field.
  • In Hasura, add a remote join extending this mutation with a new field, updatedUser: User, which joins UpdateUser.updated_user_id to the user.id record. Just like it's possible with Actions.
  • This would allow GraphQL clients, like the Apollo Client, to automatically update the record locally, without having to refetch the data.

Is there any update related to when this feature is going to become available? Or if it's planned at all. Anything the community can do to help with the development of this?

This is the exact use case that I've run into when using remote schemas and as its supported through Hasura Actions I really hope that it drops soon! This is basically the last missing piece for incredibly deep integration with Remote Schemas that could make things ready for primetime

coco98 commented 3 years ago

Hi folks, we have a PR to start trying this feature out! Currently via metadata only, and we'll be merging in other finishing touches and the console soon.

https://github.com/hasura/graphql-engine/pull/7647

Would love your feedback and any comments you have.

Ant59 commented 2 years ago

Will we likely see this merged soon?

ahobsonsayers commented 2 years ago

This is finally implemented in Hasura v.2.5.0 🎉🎉🎉 Thanks to all those who were involved in getting this out, it works great!

Sadly you cannot manage relationship via the console yet, but you can see some notes on how to make remote schema relationships via the API in the v2.5.0 release changelog here.

For anyone else that likes to manage metadata via yaml files and use the Hasura CLI, here is what i did to get remote schema to database relationships working.

In your remote_schemas.yaml

- name: my_remote_schema
  definition:
    url_from_env: MY_REMOTE_SCHEMA_URL
    forward_client_headers: true
    timeout_seconds: 60
  remote_relationships:
    - type_name: MyType
      relationships:
        - name: my_remote_relationship
          definition:
            to_source:
              relationship_type: object
              source: my_database
              table:
                schema: public
                name: my_table
              field_mapping:
                my_remote_field: my_table_column