Open javiertoledo opened 3 years ago
can I pick up this issue?
Hi @renansoares, yeah, I think that nobody else is working on it. Feel free to assign it to you. If you have questions, you can reach out the @boostercloud/booster-core team here or in Discord (find the link in https://booster.cloud). Thanks!!
hey @renansoares, actually I'm doing some work that affects the GraphQL query schema. My work involves the graphql-query-generator.ts
and graphql-type-informer.ts
, just have in mind that if you are going to work on them, there might be conflicts.
Reviewing #575 I realized that we needed to introduce a default NoOp query when no queries are defined to fix an error with GraphQL schema validations, and digging a little bit I found that it could make sense to rework the schema generation code a little bit to manage these situations better.
In the current implementation, the
generateSchema
function is the final step to build theGraphQLSchema
object, and the fix in #575 is a workaround to avoid thequery
being empty and making the validation fail:Looking at the
GraphQLSchema
class implementation in thegraphql
package, we can see that all the config parameters are actually optional, so I guess that not initializing them could be a better fix:Back to our code, looking at the class
GraphQLGenerator
, we can see that the process involves creating and initializing many objects that are actually only depending on theconfig
:I'd propose to rework this code as a sequence of static function calls that receive the
config
and return back the right object for each of the fields required by theGraphQLSchema
constructor, avoiding all these initialization and injection of dependencies that are obfuscating this code. In this way, it will be easier to build the finalGraphQLSchemaConfig
only with the fields that make sense, not requiring us to generate the extraNoOp
query, and likely avoiding other possible similar bugs that we haven't found yet.