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

Return empty array instead of null

Open EinDev opened this issue 4 years ago • 0 comments

I'm pretty new to GraphQL, maybe this is a user-error. Let's say i have a table "person" with the following JSON Schema:

{
    type: 'array',
    required: ['username'],
    properties: {
        username: { type: 'string' },
        stringList: {
            type: 'array',
            items: {
                type: 'string'
            }
        }
    }
}

And the following GraphQL-Query:

{
    profile(username: "test") {
        stringList
    }
}

I would expect it to return:

{
    stringList: []
}

But it returns:

{
    stringList: null
}

According to some StackOverflow Post i would need to modify the GraphQL-Schema, that gets generated by objection-graphql. Is there any way to achieve this with objection-graphql?

EinDev avatar Jul 08 '21 19:07 EinDev