meitinger / GraphSPARQL

GraphQL to SPARQL bridge
GNU General Public License v3.0
22 stars 4 forks source link

Create-operation using JSON provider #4

Open hugovanversendaal opened 1 year ago

hugovanversendaal commented 1 year ago

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.

meitinger commented 1 year ago

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?

hugovanversendaal commented 1 year ago

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