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

Action relationships are not working

Open VladimirCourse opened this issue 6 years ago • 2 comments

Hello! I'm trying to create action handler with custom types and relationship (as in documentation):

image

type Mutation {
  auth_confirm (
    phone: String!
    code: String!
  ): AuthConfirmOutput
}
type AuthConfirmOutput {
  token : String!
  userId : uuid
  loggedUser: user
}

After action save it gives error:

validation for the given custom types failed because the type "user" for field "loggedUser" in object type "AuthConfirmOutput" does not exist

What I am doing wrong? (I am new for Hasura and sorry if my question is silly).

VladimirCourse avatar Aug 28 '20 18:08 VladimirCourse

I think if you remove loggedUser:user it should work. You don't have to define the object relationship in the Output.

goodmase avatar Aug 28 '20 20:08 goodmase

Finally, found that problem was in permissions: it was needed to make anonymous role able to select users from table. And yes, it doesn't need "loggedUser" in object (as in comment above). Also, probably documentation need some corrections here: https://hasura.io/docs/1.0/graphql/core/actions/reuse-types-actions.html

VladimirCourse avatar Aug 29 '20 09:08 VladimirCourse