pg_graphql
pg_graphql copied to clipboard
pg_graphql does not generate schema for array typed properties on mutation.
Describe the bug
Whenever I use the codegen to create the types from the queries it does not generate the properties with [Int] for the update type:
For example, the type "Profile" is correctly generated as:
type profiles {
birthday: Date
can_be_roommate: Boolean
created_at: Datetime
description: String
display_name: String!
employment: Int
first_name: String!
id: BigInt!
last_name: String!
search_as: Int
tenant_attributes: [Int]
user_id: UUID!
}
But its mutation type is missing the tenant_attributes
input profilesUpdateInput {
birthday: Date
can_be_roommate: Boolean
created_at: Datetime
description: String
display_name: String
employment: Int
first_name: String
last_name: String
search_as: Int
user_id: UUID
}
Error: × GraphQL Document Validation failed with 1 errors; Error 0: GraphQLDocumentError: Field "tenant_attributes" is not defined by type "profilesUpdateInput". Image
To Reproduce Steps to reproduce the behavior:
- Create a table with an array property. Eg. Int[]
- Add graphql plugin to table/db
- Get the schema via. the graphql endpoint
- Notice the update type
Expected behavior It should also include the array properties in the mutation types
Versions:
- PostgreSQL: Supabase
- pg_graphql: Whatever is on supabase
Array types on mutations are not currently supported but it's something we're actively working towards. I'd expect it to land on the hosted platform in the next couple months
Probably good idea to add this fact to the readme :)
Is there another way to make an API call to update an array field on a table? Could we work around by using the REST endpoint? @olirice This is blocking me from moving forward.
Yes, PostgREST does support updating an array column. You can achieve that with supabase-js
if you're on the supabase platform or postgrest-js
if not
@olirice thank you for the suggestion, I'm looking at the documentation now.