Skip to content
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

[v1.3.0-beta.2] Error remote relationship: cannot validate remote relationship because expected type \"Int\" but got \"Int\" #5133

Closed
kuzmi4 opened this issue Jun 18, 2020 · 11 comments · Fixed by #5603
Labels
c/remote-joins Related to remote joins support/needs-action support ticket that requires action by team

Comments

@kuzmi4
Copy link

kuzmi4 commented Jun 18, 2020

Hi

Steps to reproduce:

  1. Create table with remote Int Column
  2. Add remote scheme with "Int" type
  3. Try create remote relationship
[
    {
        "definition": {
            "remote_field": {
                "bot_directions": {
                    "arguments": {
                        "key": "$direction_key"
                    }
                }
            },
            "name": "dk",
            "hasura_fields": [
                "direction_key"
            ],
            "remote_schema": "hasura-backend",
            "table": {
                "schema": "public",
                "name": "bot_groups"
            }
        },
        "reason": "in table \"bot_groups\": in remote relationship\"dk\": cannot validate remote relationship because expected type \"Int\" but got \"Int\"",
        "type": "remote_relationship"
    }
]
@rikinsk rikinsk added c/remote-joins Related to remote joins support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog labels Jun 19, 2020
@timrbula
Copy link

Per guidance in Discord preview channel, I'm adding another error example I encountered trying to create a remote relationship with a sanity.io schema. The goal is to store the "likes" by a user on a sanity object in postgres and be able to get back the user's likes and data about the object with a single query.

Steps to reproduce:

  1. Create sanity.io dataset and deploy autogenerated GraphqQL schema for it. Add as remote schema in Hasura instance.
  2. Create table w/ text column
  3. Add remote schema to "id" field on sanity object
  4. Try to create remote relationship

Error

[
    {
        "definition": {
            "remote_field": {
                "Experiences": {
                    "arguments": {
                        "id": "$experience_id"
                    }
                }
            },
            "name": "experience_instance",
            "hasura_fields": [
                "experience_id"
            ],
            "remote_schema": "sanity",
            "table": {
                "schema": "public",
                "name": "likes"
            }
        },
        "reason": "in table \"likes\": in remote relationship\"experience_instance\": cannot validate remote relationship because expected type \"ID\" but got \"String\"",
        "type": "remote_relationship"
    }
]

I also tried with a uuid column but got the same error. I assume the issue is with the ID type on the sanity schema but I am a bit confused with it being a standard gql scalar type that I also assume is pretty common. If it doesn't map to a text or uuid column what would it map to?

@mingfang
Copy link

mingfang commented Jul 10, 2020

I ran into the same problem.
I'm surprise more people are not seeing this since virtually every remote join will be on a remote ID field but you can't create a source field of that type.

@philschonholzer
Copy link

philschonholzer commented Jul 19, 2020

Also got the same problem with sanity.io using v1.3.0-beta.4

@philschonholzer
Copy link

Problem can still be reproduced on v1.3.0 release.

@tirumaraiselvan
Copy link
Contributor

tirumaraiselvan commented Jul 21, 2020

The issue here is that the graphql types must be exactly the same for the remote relationship to be valid. You cannot join String with ID as such. Although I do agree that coercing values is useful.

I also agree that ID field is very common identifier type in Remote Schemas and there should be a way to make ID types in Hasura. We already have an issue tracking this: #2881 . Let's continue discussion in this issue.

As for the OP's issue:

@kuzmi4 Can you give the table definition and a sample remote schema definition which is causing this failure? I am not able to reproduce this.

@tirumaraiselvan tirumaraiselvan changed the title [v1.3.0-beta.2] Error remote relationship with same types [v1.3.0-beta.2] Error remote relationship: cannot validate remote relationship because expected type \"Int\" but got \"Int\" Jul 21, 2020
@tirumaraiselvan tirumaraiselvan added support/needs-more-info Needs more details/info/repro instructions and removed support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog labels Jul 21, 2020
@kuzmi4
Copy link
Author

kuzmi4 commented Jul 23, 2020

I made demo scene with same problem

Hasura: https://issues-5133.herokuapp.com/console
Remote scheme: https://glitch.com/edit/#!/honored-clover-jumper?path=index.js%3A35%3A14

Just try add remote relationship

@tanmaypatil
Copy link

Interestingly i am not able to map string to string field also

  • I have remote query which has String! as input variable (id)

  • In remote relationship , i try to map it to text column of the table

,"reason":"in table \"vam.physical_account\": in remote relationship\"fetch_bal\": cannot validate remote relationship because type \"Account\"only objects or scalar types expected","type":"remote_relationship"}],"path":"$.args[0].args","error":"in table \"vam.physical_account\": in remote relationship\"fetch_bal\": cannot validate remote relationship because type \"Account\"only objects or scalar types expected","code":"constraint-violation"}

@tirumaraiselvan
Copy link
Contributor

@kuzmi4 Thank you for the repro and sorry for the delay. We will fix it ASAP.

@tanmaypatil The error message seems to not talk about the type of Account. It should ideally print that as well. We will fix the error message. Meanwhile, can you show the definition of the remote relationship by showing the API call from the network tab when you try to create this?

@tanmaypatil
Copy link

tanmaypatil commented Aug 18, 2020

@tirumaraiselvan


Please note that account is query type.


request url http://localhost:9693/apis/migrate
Payload { "name": "table_physical_account_create_remote_relationship_map_phy_acct", "up": [ { "type": "create_remote_relationship", "args": { "name": "map_phy_acct", "remote_schema": "phy_acct", "remote_field": { "account": { "arguments": { "id": "$account_number" } } }, "hasura_fields": [ "account_number" ], "table": { "name": "physical_account", "schema": "vam" } } } ], "down": [ { "type": "delete_remote_relationship", "args": { "name": "map_phy_acct", "table": { "name": "physical_account", "schema": "vam" } } } ], "skip_execution": false }

Response is `{"code":"data_api_error","message":"{"internal":[{"definition":{"remote_field":{"account":{"arguments":{"id":"$account_number"}}},"name":"map_phy_acct","hasura_fields":["account_number"],"remote_schema":"phy_acct","table":{"schema":"vam","name":"physical_account"}},"reason":"in table \"vam.physical_account\": in remote relationship\"map_phy_acct\": cannot validate remote relationship because type \"Account\"only objects or scalar types expected","type":"remote_relationship"}],"path":"$.args[0].args","error":"in table \"vam.physical_account\": in remote relationship\"map_phy_acct\": cannot validate remote relationship because type \"Account\"only objects or scalar types expected","code":"constraint-violation"}"}
account query type

@codingkarthik
Copy link
Contributor

@kuzmi4 From the error message it seems that you were trying to create a remote relationship between Int and [Int], if that is the case, it'll be fixed via this PR. The same error may also be thrown if you're trying to join [Int] with Int (which seems unlikely because hasura doesn't support native array types for table columns), but with the above PR the error message will show exactly what types are being attempted to join.

@kuzmi4
Copy link
Author

kuzmi4 commented Aug 21, 2020

@codingkarthik good news. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/remote-joins Related to remote joins support/needs-action support ticket that requires action by team
Projects
None yet
8 participants