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.03k stars 2.76k forks source link

[Feature Request] I want to create Object Relationshp with fixed values. #10318

Closed toki-developer closed 1 month ago

toki-developer commented 2 months ago

Component

c/v3-engine

Is your proposal related to a problem?

I want to create object relationships with fixed values for sorting.

Example: table primary key
account wallet_address
blockchain wallet_address, chain_id
Relationship Name conditions
ethereum account.wallet_address = blockchain.wallet_address
blockchain.chain_id = 1
polygon account.wallet_address = blockchain.wallet_address
blockchain.chain_id = 137
... ...

I want to get data from account.ethereum, account.polygon, etc. It is possible to use an Array Relationship and retrieve data with a query using where:{chain_id:{_eq:1}}, etc. However, since it is an Array Relationship, it cannot be sorted.

※ Please do not point out the composition since it is an example. I want to create a Relationship using fixed values.

manasag commented 1 month ago

Hi this is supported in Hasura v3 (See docs) E.g. relationship definition can be:

kind: Relationship
version: v1
definition:
  name: ethereum
  sourceType: account
  target:
    model:
      name: blockchain
      subgraph: blockchain
      relationshipType: Object
  mapping:
    - source:
        fieldPath:
          - fieldName: wallet_address
      target:
        modelField:
          - fieldName: wallet_address
    - source:
        value: 
          literal: 1
      target:
        argument:
         argumentName: chain_id
toki-developer commented 1 month ago

I did not know that. Thank you very much. This Issue is closed.