GraphSPARQL icon indicating copy to clipboard operation
GraphSPARQL copied to clipboard

Create-operation using JSON provider

Open hugovanversendaal opened this issue 1 year ago • 2 comments

Hi,

I'm trying to perform a mutation that creates a new triple and inserts it to a datasource using the JSON provider. Suppose I use the following JSON provider file:

{
    "Mutation": {
        "Fields": [
            {
                "Name": "createPerson",
                "Object": "Person",
                "DataSource": "my-triplestore",
                "IsArray": false
            }
        ]
    },
    "Types": [
        {
            "Name": "Person",
            "Namespace": "http://fake-namespace.com/person",
            "DataSource": "my-triplestore",
            "Fields": [
                {
                    "Name": "firstName",
                    "Scalar": "String"
                },
                {
                    "Name": "lastName",
                    "Scalar": "String"
                }
            ]
        }
    ]
}

What query should I use to add a new person to my triplestore? I've tried to simulate the example from the README, that uses a template argument, but I cannot use that argument by default.

hugovanversendaal avatar Apr 19 '23 14:04 hugovanversendaal

Sorry for the late reply.

Alas, how to define mutations manually is not covered in the README. As you can see in the RDF harvester, create... fields always get the predicate https://schema.uibk.ac.at/GraphSPARQL/createset. This is necessary to "know" it's a create operation (we don't rely on the name), and to pull in the id and template arguments. So you need to also set add "Predicate": "https://schema.uibk.ac.at/GraphSPARQL/create" in your createPerson field.

If this solves your issue, feel free to submit a PR with an updated README :)

If not, can you post your updated schema and exact mutation?

meitinger avatar May 09 '23 14:05 meitinger

Thanks for the explanation! I'll give it a try and let you know what the outcome is.

hugovanversendaal avatar May 19 '23 11:05 hugovanversendaal