anvilco / spectaql

Autogenerate static GraphQL API documentation
https://useanvil.com/docs/api/graphql/reference/
MIT License
1.12k stars 118 forks source link

should dynamic example generator have access to introspection query result ? #904

Open sheunglaili opened 1 year ago

sheunglaili commented 1 year ago

Right now in dynamic example generators, we have type, field,arg,inputField,underlyingType,isRequired,isArray,itemsRequired. It will be easier to generate example if the current field is SCALAR. However, when generating example with nested object, we can only limited to generating [Typename] as we don't know what's the field of the Type contains. Is it possible to pass in the introspection query results or even the microfiber object so we have the possibility to expand or customise the example of nested object?

example: we can only generate example like:

{
  "field1": Field1Type
}

but we can't generate

{
  "field1": {
      "innerfield1": "randomValue",
      "innerfield2": "randomValue2"
   }
}

I have applied the directive example as of now but it's difficult to maintain since you have to add example for the query response and also to the type itself.