juancastillo0 / leto

Dart GraphQL server libraries. Utilities, code generator, examples and reference implementation.
https://juancastillo0.github.io/leto/
MIT License
41 stars 6 forks source link

Update documentation to mention explicit import of schema definition files #22

Open tigloo opened 9 months ago

tigloo commented 9 months ago

Feel free to ignore this one as I almost feel stupid for saying it, but it took me some time to figure this out.

The documentation should be updated to mention that schema definitions need to be imported somewhere in order to be available.

I ran into the following situation:

When writing a query for the entity "Patient", it is not possible to use the spread operator "managingOrganization { ...on Operation {} }" or "managingOrganization {...on Practitioner {} }" if the object types "Organization" and "Practitioner" are not imported somewhere.

The reason for this is that the schema is defined through global getters which are only executed if the files containing them are imported somewhere. But since the query code itself only imports the base interface "Resource", this didn't happen.

I implicitly expected that the schema generator picks up all schema definitions and includes them in graphql_api.schema.dart, but this is not the case.