graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

Joining from a database table to an action result and/or expanded filtering/aggregated when joining via action relationship

Open gstewart-aiwyn opened this issue 3 years ago • 2 comments
trafficstars

Currently, we can only link actions to database entities via action relationships. However, this functionality is extremely limited. There is no ability to filter out results or iterate. It would also be nice to be able to join from a table to an action result so you can get a superset of the table entity against the action dataset when the action is of type query.

gstewart-aiwyn avatar Jun 08 '22 16:06 gstewart-aiwyn

Hello everybody! I have a related use case, where I need to extend the GraphQL schema by joining with the result of a query action.

Suppose the following example:

  1. There's a local_table table stored in my Hasura project's primary database with the external_table_id column on it, and exposed via graphql.

  2. I've defined a query action to get data from a third party REST API, defined as follows:

    # in actions.yaml
    actions:
      - name: external_table
        definition:
          kind: ""
          handler: http://thirdpartyserver
        permissions:
          - role: anonymous
        comment: Get external table
    
  3. The output of this actions is:

    type ExternalTable {
      id: Int!
      # additional information
    }
    

    The column external_table_id works as a FK to the ExternalTable.id column

In this scenario, I'd like to run the following query:

query MyQuery {
  local_table {
    id
    external_table_id
    external_table {
      id
      # the rest of the available fields
    }
  }
}

Would this be possible to implement?

m-revetria avatar Jun 27 '22 12:06 m-revetria

Thanks everyone for your comments and patience on this issue. We have been closely listening into all the feedback and requests from the community, and have been working on a re-imagined, re-architectured Hasura, that tackles many of these issues from ground up.

We are pleased to announce that we have launched V3-Alpha of Hasura (Data Delivery Network). It is quite possible that the data-connector centric approach of V3 would obviate the need for specific support for actions and relationships between them and other entities.

Do let us know if more is needed to address what you want to achieve with your API.

plcplc avatar Jan 04 '24 09:01 plcplc