fluree / core

Fluree releases and public bug reports
0 stars 0 forks source link

Update `/transact` syntax to replace `ledger` with `@graph` + `@id` #20

Closed aaj3f closed 10 months ago

aaj3f commented 11 months ago

Description

Similar to fluree/core#19, the syntax of the http-api-gateway /transact endpoint needs to be updated to be standards-compliant rather than use the Fluree proprietary syntax of { ledger: "example/ledger", txn: { ... } }

The JSON-LD compliant way of naming the graph/ledger to which a dataset belongs is to use the top-level keys @id + @graph, such that the @id becomes the identifier/name of the graph/ledger and @graph describes the data existing within that graph/ledger. Thus, the following two examples specify, first, the current syntax used by http-api-gateway and, second, the desired, standards-compliant syntax

{
    "ledger": "example/ledger",
    "txn": {
        "@context": { "schema": "http://schema.org/" },
        "@id": "schema:fluree",
        "@type": "schema:Organization",
        "schema:description": "We ❤️ Data"
    }
}
{
    "@context": { "schema": "http://schema.org/" },
    "@id": "example/ledger",
    "@graph": {
        "@id": "schema:fluree",
        "@type": "schema:Organization",
        "schema:description": "We ❤️ Data"
    }
}

Implementation Details

A few considerations:

{
    "@context": { ... },
    "@graph": [
        {
            "@id": "ledger/one",
            "@graph": {
                "@id": "ex:andrew",
                "schema:name": "Andrew"
            }
        },
        {
            "@id": "ledger/two",
            "@graph": {
                "@id": "ex:ben",
                "schema:name": "Ben"
            }
        }
    ]
}
mpoffald commented 11 months ago

How is this new top-level "@context" meant to interact with the existing "defaultContext" behavior? Are they the same thing? If not, how are they different?

mpoffald commented 11 months ago

Ok, having thought about this more I think I understand -- the top-level @context is just the same context that would've ordinarily been inside the txn? And therefore has nothing to do with defaultContext.

I just thought it seemed weird to be able supply both defaultContext and @context, and then got confused about what that would mean.