Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(form): multiple files in file questions #1809

Merged
merged 3 commits into from
Jul 5, 2022

Conversation

winged
Copy link
Contributor

@winged winged commented Jul 1, 2022

Change the model to allow multiple files per answer to be stored. Migrate
the existing questions to the new question type, and migrate the existing
answers to the new schema.

Updated the GraphQL schema to allow saving and updating multiple files
on an answer. The answer's value is a list of dicts, each containing
a file name, and optionally an ID. When you're creating new files,
add an entry without ID to the value. Caluma will then save the file,
and return it back WITH and ID.

BREAKING CHANGE: This renames the question type constant for file questions,
and changes the semantics of the answer value for file questions as well:
It is now a list of dicts instead of a single string. The response type
for querying file(s) answers now also is a list instead of a single dict.

For details / RFC see #1780

The original Graphene API allows adding an `Input` (or, without Relay, a
`Arguments`) class to be added on mutation classes. Caluma derives it's
inputs solely from the attached serializer.

This fails if the required data type is more complex than what can
be represented on the serializer, whose most complex type is a list
of strings.

However, we need a list of well-defined objects, so we check on the
mutation class to see if a more specific field type is declared, and
use that one in the schema.
The reopen case mutation had a "required" ID in the schema, but when
regenerating, the requiredness was removed. Thus, adding an explicit
`required=True` to keep the semantics as has been.

Implicitly, the schema takes on the docstring of the `workItems` parameter
as well
@winged winged force-pushed the feat_multi_file_question branch 3 times, most recently from 3882d1c to 4552538 Compare July 4, 2022 08:27
@winged winged marked this pull request as ready for review July 4, 2022 08:28
@winged winged force-pushed the feat_multi_file_question branch 11 times, most recently from 88e51e8 to 0ab8917 Compare July 4, 2022 17:14
Change the model to allow multiple files per answer to be stored. Migrate
the existing questions to the new question type, and migrate the existing
answers to the new schema.

Updated the GraphQL schema to allow saving and updating multiple files
on an answer. The answer's value is a list of dicts, each containing
a file name, and optionally an ID. When you're creating new files,
add an entry without ID to the value. Caluma will then save the file,
and return it back WITH and ID.

BREAKING CHANGE: This renames the question type constant for file questions,
and changes the semantics of the answer value for file questions as well:
It is now a list of dicts instead of a single string. The response type
for querying file(s) answers now also is a list instead of a single dict.
@winged winged enabled auto-merge July 5, 2022 08:39
@winged
Copy link
Contributor Author

winged commented Jul 5, 2022

Merging, as @open-dynaMIX approved off-github

@winged winged merged commit dc3a224 into projectcaluma:main Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant