Open geel9 opened 1 year ago
The group discussed this issue in the 2024-07-30 telecon:
The group agreed that QueryByExample is under-specified today and the only way to answer the questions asked in this issue is to write one or more PRs that clearly answers each question.
@geel9 wrote:
Are the
@context
and type fields required or optional?
The @context
entry is required. type
is optional, but is expected to be heavily used in queries.
What is the datatype of these fields? I am operating under the assumption that they are both string | string[] -- is this fair?
For @context
, what is allowed is specified here: https://www.w3.org/TR/vc-data-model-2.0/#contexts
For type
, it can either be a string or an array of strings.
How are the
@context
and type fields to be handled? I am operating under the assumption that every value in the example@context
array (whether it be expressed as an array of strings or a string itself) must be present in the credential's@context
array, but additional values may be present in the credential's@context
array. Is this fair? I am operating under an equal assumption for the type field.
Yes, those are safe assumptions to make.
Is credentialSubject limited to only id and name fields, or is it intended for arbitrary key/values to query against the credential's credentialSubject?
It's intended for arbitrary key/values to query against the verifiable credential.
Assuming credentialSubject is not limited to id and name, how is comparison meant to be handled?
Comparison is only to be performed based on the primitive types. Matching string "5" vs. integer 5 is not expected to be performed.
Comparisons of objects is also intuitive -- just recurse.
Yes, correct.
I am assuming, however, that all object comparisons (including the top-level example.credentialSubject to credential.credentialSubject comparison itself) are loose in the sense that the object on the credential may have additional fields not specified by the example object.
Yes, that is correct.
How should one perform a comparison of arrays?
In general, we've tried to stay away from complex queries such as the ones you suggest because the use cases that most of the community is tackling doesn't require that sort of fine-grained querying. That said, arrays are presumed to be "unordered" so if there is a match, you return the credential (even if items are out of order). IOW, the query you provided would match and the credential should be returned.
The group will try to clarify these items in a future PR.
@msporny — Please code fence the @context
occurrences in the (first and third) quote blocks above. I'm sorry GitHub still hasn't figured out how to preserve codefences when automatically quoting!
Hello,
I have some questions regarding the proper handling of
QueryByExample
objects.I understand that many of these questions may not yet have answers, but I'd appreciate any insight that can be provided.
@context
andtype
fields required or optional?string | string[]
-- is this fair?@context
andtype
fields to be handled?@context
array (whether it be expressed as an array of strings or a string itself) must be present in the credential's@context
array, but additional values may be present in the credential's@context
array. Is this fair?type
field.credentialSubject
limited to onlyid
andname
fields, or is it intended for arbitrary key/values to query against the credential'scredentialSubject
?You can request a specific subject id
, which implies that that is the only intended usage.credentialSubject
is not limited toid
andname
, how is comparison meant to be handled?5
match"5"
?) should be clarified.example.credentialSubject
tocredential.credentialSubject
comparison itself) are loose in the sense that the object on the credential may have additional fields not specified by the example object.Array Comparison in
credentialSubject
(This is all assuming that the
credentialSubject
field in the example query is not restricted toid
andname
fields)Given the following query:
And the following
credentialSubject
from a VerifiableCredential:It's not entirely clear how to handle this query by example.
primitive_array_one
primitive_array_one
contains all values of the example'sprimitive_array_one
, in the same order and position, but it has additional entries.primitive_array_two
primitive_array_two
contains all values of the example'sprimitive_array_two
, and has no additional values, but they are not in the same order.complex_array
a
value equal to1
, and an object with ab
value equal to2
.a
value equal to1
, and an object with ab
value equal to2
.