You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
Currently the mutation (at least the one pushing the data to the in-memory store) uses an incorrect context, which seems to be working fine on the surface, but generally is wrong and can lead to incorrect behavior in some (edge) cases. However, when we use the correct context instead some queries break.
We need to ensure the correct context is used inside the API and it gives the expected results on the query-level.
Details
Let's use the ontology from our documentation.
Whenever we convert our JSONs to RDF inside Staple API, e.g.,
when pushing inputs to the in-memory back-end
when reading objects from MongoDB and putting and converting them to RDF in cache
Basically it's about distinguishing between object properties and datatype properties. The current schema-generating script already creates context 1 additionally to context 2 and puts it into the schemaMapping object as schemaMapping["@context2"]. We need to use both contexts in different cases because context 2 is suitable only for the user for converting GraphQL responses (so it should be still exposed via _CONTEXT query), as they are of slightly different shape than JSONs that we use in the inputs and in MongoDB.
You can see the different behavior when converting data to RDF:
The object in the triple in the first case is interpreted as a node, which is correct, and in the other case as a string, which is wrong.
Now, when we tried to replace the contexts in the pushObjectToBackend on the in-memory adapter the data in the database was created correctly, but then the querying broke. So this has to be fixed thoroughly across the entire API.
Tests:
Here are two tests that should verify the correct implementation:
test 1:
Load the following data into the Staple API using the pushObjectToBackend method:
Problem:
Currently the mutation (at least the one pushing the data to the in-memory store) uses an incorrect context, which seems to be working fine on the surface, but generally is wrong and can lead to incorrect behavior in some (edge) cases. However, when we use the correct context instead some queries break.
We need to ensure the correct context is used inside the API and it gives the expected results on the query-level.
Details
Let's use the ontology from our documentation.
Whenever we convert our JSONs to RDF inside Staple API, e.g.,
we should be always using this context:
context 1:
instead of this one:
context 2:
Basically it's about distinguishing between object properties and datatype properties. The current schema-generating script already creates context 1 additionally to context 2 and puts it into the
schemaMapping
object asschemaMapping["@context2"]
. We need to use both contexts in different cases because context 2 is suitable only for the user for converting GraphQL responses (so it should be still exposed via_CONTEXT
query), as they are of slightly different shape than JSONs that we use in the inputs and in MongoDB.You can see the different behavior when converting data to RDF:
This gives:
Instead:
This gives:
The object in the triple in the first case is interpreted as a node, which is correct, and in the other case as a string, which is wrong.
Now, when we tried to replace the contexts in the
pushObjectToBackend
on the in-memory adapter the data in the database was created correctly, but then the querying broke. So this has to be fixed thoroughly across the entire API.Tests:
Here are two tests that should verify the correct implementation:
test 1:
Load the following data into the Staple API using the
pushObjectToBackend
method:Verify that the database contains this RDF data:
Now query for:
You should get the full answer with
employee
andcustomerOf
fields populated as expected.Test 2:
Insert the same but with mutations:
Follow the same steps as before.
The text was updated successfully, but these errors were encountered: