Both the “interviews” and the “assignments” query in GraphQL take a questionnaireId field for filtering.
However, any value I assign to it gets rejected:
“The specified value type of field
questionnaireId does not match the field type.”
I tried these variations:
- questionnaireId: “0cfa3acc95b0444a89b4b83aaee6c382”
- questionnaireId: “0cfa3acc95b0444a89b4b83aaee6c382$1”
- questionnaireId: “0cfa3acc-95b0-444a-89b4-b83aa-ee6c382”
- questionnaireId: “0cfa3acc-95b0-444a-89b4-b83aa-ee6c382$1”
Variation 2 works for the assignments endpoint in the standard API.
Did anyone succeed to filter GraphQL queries by questionnaireId?
Which format did you use?
Format shown under #1 should be used:
Questionnaire ID (identifier) is the GUID: 26213482-6864-45fe-b718-d8481a14051b
Questionnaire Identity is the GUID$Version: 26213482-6864-45fe-b718-d8481a14051b$2
Any query supporting questionnaire Identity should not require or even permit questionnaire version separately (to avoid contradictions). Hence you know, if the version is declared as a parameter, it is not part of the ID.
For assignments I don’t see the questionaireId declared as a property of an assignment:
I know it isn’t included as a node to be returned, but the questionnaireId field is accepted for filtering.
As I said in my post:
When I include it in the where clause it accepts the field, but not its value:
As I mentioned I tried with the 4 variations. All show the same error.
True. QuestionnaireIdentity is a composite object (In contrast to primitive types, like string or integer number).
So, compare by matching individual attributes (in this case id and version).
Try the following:
Perfect. This works!
Unfortunate only that
- this is not documented in the schema
- elsewhere the node with the same name (questionnaireId) returns a simple string (as in your first example).
Yes, agree on both points. It took me a while to figure out why there is any confusion there.
Still, it is perfectly legal for two objects to have the same name for their properties which are of different types, which happened to be the case here.
An id, for example could be
- a number in one object (like an assignment) and
- a GUID in a different (like an interview), and
- an ID type in yet others (questionnaires).
I find dgraph.io documentation very accessible and with a good level of detail, and with a reasonable number of examples:
It is described in application to a different software, but demonstrates the useful GraphQL’s principles, and I felt was worth skimming through.
Well, many posts on this forum serve as documentation of things not easily found elsewhere.
So is this one. In this spirit I would like to add another observation I discovered during testing:
Although the questionnaireId field for filtering assignments takes as value a composite object with an id component and a version component, the version component is optional. If not specified all versions are searched.
Likewise the questionnaire ID is also optional. One can specify just
to retrieve information only from the 4-th versions, regardless of the survey. Whether this is practical, though, is a different matter.