-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
New JSON facets response format cannot be unserialized back into client structures #4798
Comments
I think I am having the same issue as @mehdiym |
@mileung the result is correct. This is the new facet's behavior. |
Hi all, we have discussed facets format internally and prepared one document with different possible formats. Please checks below discuss post and provide your feedback. |
Fixes: #4798, #4581, #4907 DGRAPH-1109, DGRAPH-1062, DGRAPH-1143 This is PR changes facets format as discussed in the post: https://discuss.dgraph.io/t/facets-format-in-mutation-requests-and-query-responses/6416 After this PR is merged response/requests formats will look like as below: Current UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California" }, "state|capital": false } ] } } New UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California", "state|capital": false } } ] } } Current UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish" }, { "name": "Chinese" } ], "speaks|fluent": { "0": true, "1": false } } ] } } New UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish", "speaks|fluent": true }, { "name": "Chinese", "speaks|fluent": false } ] } ] } } Current scalar list predicate facets mutation request: { "set": [ { "uid": "_:1", "nickname": "Joshua", "nickname|kind": "official" }, { "uid": "_:1", "nickname": "David" }, { "uid": "_:1", "nickname": "Josh", "nickname|kind": "friends" } ] } New scalar list predicate facets mutation request: { "set": { "uid": "_:1", "nickname": ["Joshua", "David", "Josh"], "nickname|kind": { "0": "official", "2": "friends" } } } NOTE: there is no change in the request/response facets format for scalar predicate type.
Fixes: hypermodeinc#4798, hypermodeinc#4581, hypermodeinc#4907 DGRAPH-1109, DGRAPH-1062, DGRAPH-1143 This is PR changes facets format as discussed in the post: https://discuss.dgraph.io/t/facets-format-in-mutation-requests-and-query-responses/6416 After this PR is merged response/requests formats will look like as below: Current UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California" }, "state|capital": false } ] } } New UID predicate facets query response: { "data": { "q": [ { "name": "San Francisco", "state": { "name": "California", "state|capital": false } } ] } } Current UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish" }, { "name": "Chinese" } ], "speaks|fluent": { "0": true, "1": false } } ] } } New UID list predicate facets query response: { "data": { "q": [ { "name": "Alice", "speaks": [ { "name": "Spanish", "speaks|fluent": true }, { "name": "Chinese", "speaks|fluent": false } ] } ] } } Current scalar list predicate facets mutation request: { "set": [ { "uid": "_:1", "nickname": "Joshua", "nickname|kind": "official" }, { "uid": "_:1", "nickname": "David" }, { "uid": "_:1", "nickname": "Josh", "nickname|kind": "friends" } ] } New scalar list predicate facets mutation request: { "set": { "uid": "_:1", "nickname": ["Joshua", "David", "Josh"], "nickname|kind": { "0": "official", "2": "friends" } } } NOTE: there is no change in the request/response facets format for scalar predicate type.
What version of Dgraph are you using?
1.2.1
Steps to reproduce the issue (command/config used to run Dgraph).
Query for UID facets, and then try to unmarshal them into a Go struct.
Expected behaviour and actual result.
Expected: Facet values properly set.
Actual: Zero values.
I realize the facets response format has recently changed, but I don't understand how I can now unserialize it into my data structures : facets are now independent objects attached to the parent node while my Go facet properties are defined into the child node.
In the go doc example, the result is not unserialized into a Person anymore but instead into a generic
json.RawMessage
: does it mean it is not possible anymore?How can I get facets directly back into my data structures?
The text was updated successfully, but these errors were encountered: