magidoc-org / magidoc

Autogenerate static GraphQL API documentation
https://magidoc.js.org
MIT License
243 stars 19 forks source link

Silently did not run query-generator #393

Closed cfaherty closed 1 month ago

cfaherty commented 1 month ago

Describe the bug

I was having trouble getting example queries and responses generated. I believe query-generator plugin does that. I wasn't sure if it was supposed to generate them by default or if there was a hidden option.

It wasn't until I went back major version by version to 3.6.4 that I was able to get it working. In 3.6.4 magidoc generate began complaining..

Error:
Cannot generate a random value for scalar 'ZeroDateTime'.
The random generator is not able to randomly generate a value for non-standard GraphQL scalars.
You have to provide a custom factory by providing this in your magidoc config:
{
  website: {
    options: {
      queryGenerationFactories: {
        'ZeroDateTime': '<an-example-of-scalar-value>'
      }
    }
  }
}

And with that, adding in some problematic queryGenerationFactories it began working. And this includes up to version 6.

Long story short, evidently I am not getting this type of error in 6.x, and instead it silently builds the docs but without the query examples. I'm actually not able to get it to complain, but with 3.6.4 it will complain and if I fix those entries within queryGenerationFactories then it functions as expected in 6.x.

Reproduction

In the schema declare a type that querygenerationfactories cannot randomly generate a value. Then try magidoc generate. It should produce an error, but in my case it does not complain but instead the docs do not include any examples.

My custom scalar declaration:

scalar ZeroDateTime

Logs

No response

System Info

Ubuntu 22.04.04 LTS
Nodejs v20.15.1
@magidoc/cli v6.0.0

Severity

Serious, but I can work around it

pelletier197 commented 1 month ago

Thank you for investigating that. It is indeed problematic. I will investigate when I get some free time.

pelletier197 commented 1 month ago

I have found the issue. I will provide a fix ASAP.

pelletier197 commented 1 month ago

This was released in 6.0.1. Let me know if all is good on your side. Thanks again!

cfaherty commented 1 month ago

Yes it works! 💯 I get a nice error when I take out my ZeroDateTime generation factory entry.

pelletier197 commented 1 month ago

Awesome! Thanks for verifying