Vincit / objection-graphql

GraphQL schema generator for objection.js
MIT License
307 stars 35 forks source link

Return empty array instead of null #96

Open EinDev opened 3 years ago

EinDev commented 3 years ago

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?