Effect CommunityEC
Effect Community2y ago
6 replies
Gibbs

Using Schema decoding with GraphQL and non-empty arrays

Hello! When decoding input arguments from graphql, I want to use Schema.decode and not Schema.decodeUnknown to check that the gql type match at least the encoded side of my schema.
But if I want to check that an array is non empty, I cannot use Schema.NonEmptyArray because the encoded type of this schema is supposed to be a NonEmptyArray which is not defined in gql.
I would need some kind of Schema.NonEmptyArrayFromArray or simply a filter like Schema.Array(Schema.String).pipe(Schema.nonEmptyArray) that would keep a simple array in the Encoded side but a NonEmptyArray in the type side. Any advice ? Thank you in advance !
Was this page helpful?