Search code examples
hasura

How to use custom object types in Hasura actions?


I want to create an action with the following input:

input PurchaseInput {
    user: UserInfo!
}

UserInfo is defined as an object:

type UserInfo {
  accessToken: String!
  userId: Int!
}

However Hasura doens't like this and returns a 400 on saving the action.

Is it possible to define custom input types in Hasura? I feel limited by String, Int, Float, Boolean etc.


Solution

  • You can absolutely create custom types like in your example

    type UserInfo {
     accessToken: String!
     userId: Int!
    }
    

    So the error is of some other origin ( action response.... ).

    Hasura only has a limitation of nested object types, for example, you can not do type definition like this in action :

    type User {
     userId: Int!
    }
    
    type UserInfo {
     accessToken: String!
     user: User!
    }