graphile / crystal

🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
https://graphile.org/
Other
12.62k stars 571 forks source link

Easier way to create a type instance dynamically #2234

Open p-bakker opened 2 weeks ago

p-bakker commented 2 weeks ago

Feature description

When dynamically adding fields using the GraphQLObjectType_fields hook, a type is required.

However, creating a type using the existing api is quite intricate. For example, creating a type like [Orders!]! requires something along these lines: new build.graphql.GraphQLNonNull(new build.graphql.GraphQLList(new build.graphql.GraphQLNonNull(build.getTypeByName('Orders'))))

Maybe a utility method to parse a type string like '[Orders!]!' and return a type instance?

Motivating example

See https://discord.com/channels/489127045289476126/1296863704364879902/1298239516821426236

Breaking changes

Don't think so

Supporting development

I [tick all that apply]: