grooviter / gql

Groovy GraphQL library
http://grooviter.github.io/gql/
Apache License 2.0
49 stars 6 forks source link

Shortcut for queries returning a GraphQLList ? #15

Open ghost opened 7 years ago

ghost commented 7 years ago

Instead of writing

def schema = DSL.schema {
        queries {
            field('history') {
                type new GraphQLList(GraphQLHistory)
                fetcher {env -> return DATA}
            }
        }
    }

I would like to write:

def schema = DSL.schema {
        queries {
            field('history') {
                type [GraphQLHistory]
                fetcher {env -> return DATA}
            }
        }
    }
ghost commented 7 years ago

Just realized that I can write:

 queries {
            field('history') {
                type list(GraphQLHistory)
                fetcher {env -> return DATA}
            }
        }
mariogarcia commented 7 years ago

Thanks for the feedback. I've thought about this as well but I was expecting more feedback before changing anything. If I'm not wrong you were expecting something more similar to GraphQL schema definition, something like:

type GraphQLHistory // single type
type [GraphQLHistory] // list type

That is very feasible. It would mean that the related DSL supporting methods would be:

type(Class<GraphQLType> type) // single type
type(List<Class<GraphQLType>> listType) // list type

I will think about it in upcoming versions, but first I'm focusing on having a relay implementation which I think is more important. Then I will probably do a release with all received feedback like yours :)

Thanks again for the feedback, it's really important to improve the project.

ghost commented 7 years ago

Thanks four your answer. It's great that there is a nice GraphQL DSL for the JVM.