leto icon indicating copy to clipboard operation
leto copied to clipboard

Update documentation to mention explicit import of schema definition files

Open tigloo opened this issue 1 year ago • 0 comments

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:

  • An object type "Patient" has a property "managingOrganization" of interface type "Resource", which (according to the data model) could refer to object types "Organization" or "Practitioner".
  • The object types "Organization" and "Practitioner" implements "Resource".

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.

tigloo avatar Jan 11 '24 12:01 tigloo