Repository navigation
fix(json-ld): an explicit @vocab is taken as written - #2397
Conversation
A @vocab ending in neither / nor # got a / appended, so "@vocab": "urn:ex:" wrote urn:ex:/name. The vocabulary is now expanded as JSON-LD 1.1 expands it: an absolute IRI as written, a compact IRI or term expanded, a relative IRI joined to the vocabulary in effect. Query results compact with it whatever it ends in. A string @context and a @base standing in for @vocab keep the /; the @base rewrite is one function for transactions and queries.
aaj3f
left a comment
There was a problem hiding this comment.
@bplatz this is the right fix in the right place: compute_vocab now reads @vocab the way JSON-LD 1.1 does, and folding the two normalize_context_value copies into with_base_as_vocab is a nice consolidation.
On the release line, that's your call, but two things I'd weigh. I can't find a blocking reason this has to wait for 5.0: the RFC resolver is on main too, so it ports with a modest rewrite of compute_vocab. And every 4.2.x write under a @vocab like urn:ex: adds IRIs the repair recipe will later have to fix, so there's some value in landing it on main the way #2283 did.
The one thing I'd hold the merge for: a transaction parses its top-level @context twice (in extract_context, then again in the expander), and a relative @vocab now joins the vocabulary the first pass left. So {"@base": "http://example.org/doc", "@vocab": "#"} inserts …/doc##name, which a query under the same context never finds. Details and a fix Claude tried are below.
Full review below:
✅ Approving to unblock: please get the transaction's double parse of @context fixed, and the compactor's base/vocab order, before merging. Taking @vocab as written is right, and the compatibility entry is careful: Claude ran both repair updates against a ledger the merge-base wrote, and they reconnect it (list order lost, as the note says). But a relative @vocab now writes doubled IRIs through a transaction, and that one can't ship.
Before merging:
fluree-db-transact/src/parse/jsonld.rs:1393: parse the top-level@contextonce; a relative@vocabis joined twice on insert.fluree-graph-json-ld/src/compact.rs:221: let the vocabulary win over an equal@base(pre-existing from #2284;#namekeys don't read back).
Decisions on the record: My reading is that an explicit @vocab now follows the spec while a string @context and an @base standing in keep their /, so {"@vocab": "https://schema.org"} writes https://schema.orgname where "@context": "https://schema.org" still writes https://schema.org/name. I think that's the right line, but I'd like your confirmation it's the intended one.
Notes:
- This is one instance of a class we keep hitting: a context's vocabulary is resolved in several places. This PR merges the two
normalize_context_valuecopies; Cypher'sextract_cypher_iri_mappingand GraphQL'snamer_forstill read the raw@vocabtext, and SPARQL lowering copiesBASEinto@vocabon its own. The class fix is one resolver influree-graph-json-ldthat every front-end asks. For Cypher and GraphQL that's small enough to fold in here (the note oncompatibility.md:409); SPARQL's copy is consistent after this PR and can stay. - W3C register (#2396): Claude merged this onto #2396 on a box, and exactly the nine entries in the body flip. I'd land #2396 first, so this rebases and drops them; expand t0111/t0112 then differ only on
?query=worksand move to the?-variables group, while toRdf te111/te112 also keep an ill-formed…rel2##fragment-workspredicate and stay under #2395.nexthas no required checks and this PR's green run predates that job, so it needs a fresh run after the rebase. The harness parses a test's context once, so a green register wouldn't have caught must 1. - The same shape turned up on #2400: a relative
@vocabresolved twice on one path (there, a scoped context's own@vocab, joined at parse and again when it applies). The direction is one parse per context so no context-relative rule sees its own output; the point fixes are right in each PR. - Merge order: no code conflicts with #2393, #2396 or #2400 (with the last two,
compatibility.mdonly, so keep both sections), and nothing new against #2227. - A nice side effect Claude noticed: SPARQL
CONSTRUCTunderBASE <http://example.org/ns>used to emitnamefor…/ns/namebeside an@contextwhose@vocabwas…/ns, which reads back as…/nsname. It now emits full IRIs, which is consistent.
Adherence: Patterns ✔ · Performance ✔ · Deployment targets ✔ · Testing ⚠️ · Conventions ✔ · verification
- Patterns/abstractions: ✔ one rule in
compute_vocaband one fallback function, used by every JSON-LD reader; no parallel path. Cypher and GraphQL still read the raw key (Notes). - Performance (speed first, memory second): ✔ context parsing and compactor construction only, once per request; no per-row work. No performance-degradation risk.
- Deployment targets: ✔ n/a: shared string handling with no host fence involved;
wasm32andwasm-smokeare green at the head. - Testing:
⚠️ the new unit and integration tests run in CI and each goes red under mutation, but the integration test only uses absolute vocabularies, which is how the double parse got through (must 1 asks for the round trip). - Conventions: ✔ multi-line commit,
bugandbreaking-changelabels, a compatibility entry with repair updates.
Verified at 40e9e0fab: CI run 43605712830 green (17516 tests passed, the new ones among them). On a box, Claude inserted 18 @vocab shapes at the merge-base and at this head, checked insert-then-query for relative vocabularies, compaction round trips, SPARQL BASE output and Cypher, read a ledger the merge-base wrote with this head and repaired it with the documented updates, mutated each of the PR's four changes (each went red), and tried both suggested fixes (green).
Approving so you can merge once those two are in. The rest are small, and I'd rather see them folded in here than lost in the backlog.
| fn extract_context(json: &Value) -> Result<ParsedContext> { | ||
| if let Some(ctx_val) = json.get("@context") { | ||
| Ok(parse_context(&normalize_context_value(ctx_val))?) | ||
| Ok(parse_context(&fluree_graph_json_ld::with_base_as_vocab( |
There was a problem hiding this comment.
Blocking: a relative @vocab is joined twice in a transaction, so an insert writes IRIs that a query under the same context never reads.
extract_context parses the top-level @context here, and then parse_data hands the document, @context still attached, to expand_with_context_policy (jsonld.rs:433-434), whose expand_node_internal parses that same @context again on top of the first result (fluree-graph-json-ld/src/expand.rs:818-822). That was harmless while compute_vocab gave the same answer twice. Now a relative @vocab joins the vocabulary in effect, and on the second pass that's the first pass's own result.
Claude reproduced it on a box at 40e9e0fab, inserting and then querying under the same context:
| context | merge-base inserts | this PR inserts | query finds it |
|---|---|---|---|
{"@base": "http://example.org/doc", "@vocab": "#"} |
…/doc#name |
…/doc##name |
no |
{"@base": "http://example.org/a/", "@vocab": "rel/"} |
…/a/rel/name |
…/a/rel/rel/name |
no |
{"@base": "http://example.org/a/", "@vocab": "/abs/"} |
…/abs/name |
…/abs//abs/name |
no |
{"ex": "http://example.org/", "@vocab": "ex:"} |
ex:/name |
http://example.org/name |
no (it reads ex:name) |
At the merge-base the query found the row every time. An upsert takes the insert's path, so it agrees with the insert and not with the query. The last row is the same bug from another side: the second pass sees the ex the first pass defined. Neither the W3C harness in #2396 (it parses a test's context once) nor the new integration test (absolute vocabularies only) can see this.
Parsing the context once fixes it. Claude tried this in parse_data, right after strip_opts_for_expansion, and every shape above then wrote what the query reads (…/doc#name, …/a/rel/name, …/abs/name, ex:name), with the whole grp_transact binary and the fluree-db-transact unit tests still green:
// `context` already holds the top-level `@context`; expanding the document
// with it attached parses it a second time, on top of itself.
let json_for_expand = if json_for_expand.get("@context").is_some() {
let mut v = json_for_expand.into_owned();
if let Some(obj) = v.as_object_mut() {
obj.remove("@context");
}
std::borrow::Cow::Owned(v)
} else {
json_for_expand
};A round trip for "#" and "rel/" beside an @base in it_jsonld_vocab_as_written.rs would pin it. (Commenting here because jsonld.rs:426-434 and expand.rs:818-822 aren't in this diff.)
| let mut pairs: Vec<(String, String)> = flipped | ||
| .iter() | ||
| .filter(|(iri, _)| iri.ends_with('/') || iri.ends_with('#')) | ||
| .filter(|(iri, name)| iri.ends_with('/') || iri.ends_with('#') || *name == ":vocab") |
There was a problem hiding this comment.
Blocking, though most of it isn't from this PR: when @base and @vocab are the same IRI, the compactor shortens properties by the base's rule, so property names under a # base don't read back.
Your code didn't introduce the part that bites, but it lives in the table this PR changes. reverse_context (compact.rs:202-211) keys the candidates by IRI and inserts :base after :vocab, so an equal base overwrites the vocabulary and compact_vocab shortens properties and types with base_reference. Since #2284 (9dc2679b7) that writes #name under a base ending in #, and #name read back as a property is …ns##name. That's the base-as-vocab idiom ({"@base": "http://example.org/ns#"} with no @vocab, which with_base_as_vocab makes equal) and every SPARQL BASE, since build_jsonld_context_value copies it into both. And the any-ending vocabulary compaction this PR adds misses one case: an equal base and vocabulary ending in neither / nor # ({"@base": "urn:ex:", "@vocab": "urn:ex:"}) still isn't compacted at all, because the entry is now named :base and the new *name == ":vocab" never sees it.
Claude checked on a box, at the merge-base and at this head: a JSON-LD select * under {"@base": "http://example.org/ns#"} returns the key #name, and using #name back in a where finds nothing; SPARQL BASE <http://example.org/ns#> CONSTRUCT { ?s ?p ?o } … emits #frag beside an @context whose @vocab is …ns#.
Inserting the base first, so the vocabulary wins in the vocab table, fixes all three. The @id table has no vocabulary in it, so #2284's #alice for ids is unchanged. With this swap Claude saw #name come back as name and read back, urn:ex:name compact to name, and the SPARQL output emit frag, with the crate's unit tests and this PR's integration tests still green:
if include_base {
if let Some(ref base) = context.base {
flipped.insert(base.clone(), ":base".to_string());
}
}
if include_vocab {
if let Some(ref vocab) = context.vocab {
flipped.insert(vocab.clone(), ":vocab".to_string());
}
}It's two blocks swapped, and I don't think 5.0 should ship the #name keys, so I'd rather it land here than in a PR of its own. (Commenting here because reverse_context at compact.rs:202-211 isn't in this diff.)
| } | ||
|
|
||
| /// Extract namespace IRIs (ending in `/` or `#`) and sort longest-first. | ||
| /// `@vocab` joins as written, so it shortens whatever it ends in. |
There was a problem hiding this comment.
Optional: a vocabulary-compacted name can hold a :, and then it doesn't read back.
I know the body calls this out as not changed here, but this PR is what exposes urn: vocabularies to it. Under "@vocab": "urn:ex:", urn:ex:a:b now comes back from a select * as a:b, and using a:b back in a where is refused ("Unresolved compact IRI 'a:b': prefix 'a' is not defined in @context"). Claude checked this on a box. At the merge-base a urn: vocabulary never compacted, so that key came back as the full IRI and read back fine, and URN local names with colons (urn:ex:person:1) aren't unusual.
The base side already has a reads-back check (base_reference); the vocabulary side could get the same in compact_with:
if prefix_name == ":vocab" {
// A name holding `:` reads back as a compact or absolute IRI, not a term.
if allow_vocab_strip && !suffix.contains(':') {
return suffix.to_string();
}
continue;
}and ":vocab" => (allow_vocab_strip && !suffix.contains(':')).then(|| suffix.to_string()), in compact_with_tracking. This is minor and non-blocking, but if you agree it's right, I'd rather see it folded in now than lost in the backlog.
|
|
||
| #### A JSON-LD `@vocab` is taken as written (breaking) | ||
|
|
||
| A term under an explicit `@vocab` is the vocabulary joined to the term, as JSON-LD 1.1 defines. A `@vocab` that ends in neither `/` nor `#` used to get a `/` first: under `"@vocab": "urn:ex:"`, `name` and the type `Person` were `urn:ex:/name` and `urn:ex:/Person`. They are now `urn:ex:name` and `urn:ex:Person`, and under `"@vocab": "http://example.org/ns"`, `name` is `http://example.org/nsname`. A `@vocab` ending in `/` or `#` reads as before. |
There was a problem hiding this comment.
Optional (docs): two @vocab shapes that change meaning aren't named here.
"@vocab": "" is now the base as RFC 3986 resolves an empty reference, which adds no / and drops a fragment. Under "@base": "http://example.org/doc", name was http://example.org/doc/name and is now http://example.org/docname; under "@base": "http://example.org/ns#" it was http://example.org/ns#name and is now http://example.org/nsname. Claude wrote a ledger under the second at the merge-base and read it with this head, and every query under the same context came back empty. "A @vocab ending in / or # reads as before" reads as if a # base were safe, so it seems worth a sentence (for that user, writing the vocabulary out, "@vocab": "http://example.org/ns#", keeps the old IRIs).
"@vocab": "https://schema.org" now writes https://schema.orgname (also checked on the box), while "@context": "https://schema.org" keeps https://schema.org/name. http://example.org/ns shows the rule, but the authority-only form is the one people actually type without the slash, and it's where the two spellings diverge, so I think it's worth naming explicitly.
Separately, and entirely your call: joining a term to a @vocab with no path can only ever change the host, so a one-time warning for an explicit absolute @vocab with an empty path might be cheap insurance for people upgrading, the same kind of option as the warning we talked about for @base in #2284. I don't feel strongly about the warning; the two docs sentences I'd like to see either way, and since they're small I'd rather they land in this PR than in a follow-up.
| - **A config with two values for one setting-group pointer** (for example two `f:shaclDefaults` or `f:policyDefaults` groups on the config subject, typically a split config plus a corrected one written beside it). The reader now uses the non-empty group whose IRI sorts lowest; earlier releases could pick an empty one. A SHACL or policy group that had no effect therefore takes effect, including a stored `f:defaultAllow false`. Ledger info reports this as `ambiguous-pointer`. Remove the group you do not want, in the config graph. | ||
| - **Edges written through a reverse-defined term** (a context term with `"@reverse"`). With `"childOf": {"@reverse": "ex:child"}`, the node `{"@id": "ex:kid", "childOf": {"@id": "ex:mom"}}` means `ex:mom ex:child ex:kid`. Earlier releases stored `ex:kid ex:child ex:mom`, as if the term were not reversed. The term is now read as JSON-LD defines it, so the same document no longer reaches an edge an earlier release stored: deleting with it does nothing. To repair a predicate that was written only through a reverse term, flip its edges once, for example `DELETE { ?s ex:child ?o } INSERT { ?o ex:child ?s } WHERE { ?s ex:child ?o }`. If it was also written in the forward direction, select only the edges the reverse term wrote. | ||
| - **Values written through a `@vocab`, `@json` or `@index` term** (see [JSON-LD term definitions coerce values as JSON-LD 1.1 defines](#json-ld-term-definitions-coerce-values-as-json-ld-11-defines)). They keep the shape the earlier release stored, and the same context now reads and writes the new one, so a `where` pattern, a delete or an upsert written through the term no longer reaches them. A string stored through a `@vocab` term becomes the IRI with one update, here for terms relative to `http://example.org/`: `DELETE { ?s ex:status ?old } INSERT { ?s ex:status ?new } WHERE { ?s ex:status ?old FILTER(isLiteral(?old)) BIND(IRI(CONCAT("http://example.org/", STR(?old))) AS ?new) }`. Values stored through a `@json` or an `@index` term have no general rewrite (a split array does not record which values it held together): delete them by the property's full IRI and write the documents again. | ||
| - **Properties and types written under a `@vocab` that ends in neither `/` nor `#`** (see [A JSON-LD `@vocab` is taken as written](#a-json-ld-vocab-is-taken-as-written-breaking)). An earlier release stored them under the vocabulary with a `/` added. Rename the properties once, here for `urn:ex:`: `DELETE { ?s ?p ?o } INSERT { ?s ?q ?o } WHERE { ?s ?p ?o FILTER(STRSTARTS(STR(?p), "urn:ex:/")) BIND(IRI(CONCAT("urn:ex:", STRAFTER(STR(?p), "urn:ex:/"))) AS ?q) }`. Then the types and other values written through the vocabulary (`@type`, and a `@type: @vocab` term): `DELETE { ?s ?p ?o } INSERT { ?s ?p ?n } WHERE { ?s ?p ?o FILTER(isIRI(?o) && STRSTARTS(STR(?o), "urn:ex:/")) BIND(IRI(CONCAT("urn:ex:", STRAFTER(STR(?o), "urn:ex:/"))) AS ?n) }`. The second also rewrites a reference to a node whose `@id` was written under `urn:ex:/`, while the node itself keeps its id, so run it only if no ids were written that way. A list on a renamed property comes back as its members without their order; write such lists again. |
There was a problem hiding this comment.
Optional (docs): the repair could lead with the context fix, and it misses vocabulary datatypes.
For an http(s) vocabulary the IRIs an earlier release wrote (http://example.org/ns/name, https://schema.org/name) are usually the ones the user meant, so the cheaper repair there is writing the / into the @vocab ("@vocab": "http://example.org/ns/"), with no data change at all. The rename is right for a urn:-style vocabulary, where the new IRI is the intended one; for http://example.org/ns it renames good IRIs into http://example.org/nsname. Maybe lead with "if the stored IRIs are the ones you meant, add the / to the context; otherwise rename them".
Neither update renames a datatype written through the vocabulary. Claude wrote {"age": {"@value": "5", "@type": "Years"}} under "@vocab": "urn:ex:" at the merge-base (stored as urn:ex:/Years), ran both updates with this head, and the datatype was still urn:ex:/Years, so a where on the typed value still found nothing. A third update over DATATYPE(?o) (rebuilding the literal with STRDT), or a sentence saying such values need writing again, would cover it. The two updates themselves worked as written: properties and types reconnected, and the list came back unordered, as the note says.
Minor and non-blocking, but if you agree, I'd rather see it folded in now than lost in the backlog.
|
|
||
| A `@vocab` written as a compact IRI or a term now expands: after `{"ex": "http://example.org/"}`, `"@vocab": "ex:ns/"` is `http://example.org/ns/`, where it was the IRI `ex:ns/`. A relative `@vocab` joins the vocabulary already in effect (`"./rel#"` after `http://example.org/v/` is `http://example.org/v/./rel#`), and with none it resolves against `@base` as before. | ||
|
|
||
| A JSON-LD query reads its context the same way and compacts results with it, so `urn:ex:name` comes back as `name` under `"@vocab": "urn:ex:"`. Cypher already joined a ledger default context's `@vocab` as written, so under such a `@vocab` it read other IRIs than a JSON-LD write stored; the two now agree. |
There was a problem hiding this comment.
Optional: "the two now agree" holds for an absolute @vocab only.
extract_cypher_iri_mapping (fluree-db-api/src/query/helpers.rs:422-446) reads the default context's raw @vocab text, with no expansion and no @base fallback, and GraphQL's namer_for (fluree-db-api/src/graphql.rs:350-363) does the same. So the agreement your test pins holds for "urn:ex:", but Claude found Cypher still reading no rows for JSON-LD-written data under a default context of {"@base": "http://example.org/doc/", "@vocab": ""} or {"@base": "http://example.org/"}, at the merge-base and at this head; by the same code, so would a relative or compact-IRI @vocab.
This is the same "one concept resolved in several places" shape as the two normalize_context_value copies this PR merges, and the fix is the same: ask fluree-graph-json-ld for the vocabulary instead of reading the key, e.g. parse_context(&with_base_as_vocab(ctx)).ok().and_then(|c| c.vocab) in both (the Cypher one also names Cypher output, format/cypher_typed.rs:514). If you'd rather not touch those here, scoping this sentence to an absolute @vocab at least keeps the docs accurate. Minor and non-blocking, but if you agree, I'd rather see it folded in now than lost in the backlog.
…ritten # Conflicts: # docs/reference/compatibility.md # fluree-db-query/src/bm25/index.rs # fluree-db-query/src/datalog_rules/parse.rs # fluree-db-query/src/parse/mod.rs # fluree-db-transact/src/parse/jsonld.rs # fluree-graph-json-ld/src/lib.rs
…types
The compactor keyed its candidate namespaces by IRI and added the base after
the vocabulary, so a base equal to the vocabulary replaced it, and properties
and types were shortened by the base's rule. Under
{"@base": "http://example.org/ns#", "@vocab": "http://example.org/ns#"} a
select * returned the key #name, which reads back as a reference, so a where
using it found nothing; under an equal urn:ex: pair nothing was shortened.
SPARQL BASE sets both, so its JSON-LD output had the same keys.
The vocabulary now wins for properties and types. Ids still compact by the
base, so #alice is unchanged.
Under "@vocab": "urn:ex:", the IRI urn:ex:a:b compacted to the key a:b, and a:b reads back as a compact IRI with an undefined prefix, so a query using the key was refused. A name holding a : is no term, so the compactor now keeps such an IRI whole, as base compaction already keeps an id that would not read back. A urn: vocabulary only began compacting with the @vocab taken as written, and local names such as urn:ex:person:1 are common under one.
…lves it Cypher's IRI mapping (reads, writes and result names) and GraphQL's namer took a ledger default context's @vocab as its text. A relative @vocab such as "" beside an @base, or a compact IRI expanded by an earlier context, names another vocabulary in JSON-LD, so under such a context neither surface found what a JSON-LD write had stored. Both now ask fluree-graph-json-ld for the context's vocabulary, through one helper.
… that change meaning Two shapes of @vocab read differently now that it is taken as written, and the breaking-change entry did not name them. An empty @vocab is the base as RFC 3986 resolves an empty reference, without its fragment and with no / added, so under a base ending in # it no longer keeps the #. An IRI with no path, such as https://schema.org, joins a term to its host (https://schema.orgname), where a string @context of the same IRI still adds the /. Since a @vocab with no path can only ever name another host, the context parser now logs a warning, once per process, the first time it reads one.
…e datatypes Under an http(s) vocabulary the IRIs an earlier release wrote with the added / are usually the ones meant, so writing the / into the @vocab repairs the context with no data change; renaming the data suits a urn: vocabulary. The rename also missed datatypes written through the vocabulary, which kept the / after both updates, so a typed value still did not match. A third update rebuilds those literals with STRDT.
… as terms The compactor's reverse table mapped each IRI to the name that shortens it, and held @base and @vocab there under the made-up term names ":base" and ":vocab". The exact-match step did not know they were not terms, so an IRI equal to the base or the vocabulary came back as the literal ":base" or ":vocab": a node named "@id": "" under "@base": "http://example.org/doc", a reference to it, a variable bound to it, a type equal to "@vocab": "urn:ex:", and a SPARQL BASE IRI in JSON-LD output. A term defined as ":base" would also have been taken for the base. Each namespace now records what it is: a prefix term, the vocabulary or the base. Exact matching sees only terms, so an IRI equal to the base compacts as any IRI under it does (to "", or "#" under a base ending in #) or stays whole, and one equal to the vocabulary stays whole. Usage tracking records the vocabulary and the base under @vocab and @base. The compaction and tracking paths, which were two copies of one loop, are now one function.
Confirmed. Only the string
Keeping it on
Addressed in cca76a3. te111/te112 moved to the
Addressed in b552969.
Left to #2400. Also found along the way: an IRI equal to the |
An explicit
@vocabis now taken as written. A@vocabthat ended in neither/nor#used to get a/appended, so"@vocab": "urn:ex:"wroteurn:ex:/nameandurn:ex:/Person. This went through every JSON-LD reader: transactions, queries, bulk import andrdf::parse.@vocabvalue is expanded as JSON-LD 1.1 expands it (compute_vocab). An absolute IRI is used as written. A compact IRI or a term expands:"@vocab": "ex:ns/"ishttp://example.org/ns/, not the IRIex:ns/. A relative IRI joins the vocabulary already in effect, or with none resolves against@base, so an empty@vocabis the base without its fragment.@contextkeeps the/. It is Fluree's stand-in for a remote context:"@context": "https://schema.org"is the vocabularyhttps://schema.org/."@vocab": "https://schema.org"now writeshttps://schema.orgname, so the context parser logs a warning, once per process, the first time it reads a@vocabwith no path./or#as candidates. That rule is for prefixes, and it hid the vocabulary once the vocabulary was correct.{"@base": "http://example.org/ns#", "@vocab": "http://example.org/ns#"}a result had the key#name, which reads back as a reference. That is the context feat(json-ld)!: run the W3C suites, and read @base, @type and contexts as JSON-LD 1.1 does #2396 recommends in place of a lone@base, and the one a SPARQLBASEbuilds. Ids still compact by the base (#alice).:. Under"@vocab": "urn:ex:",urn:ex:a:bcame back asa:b, which reads back as a compact IRI with an undefined prefix. It now stays whole.:baseand:vocab, so an IRI equal to either came back as that literal string: under"@base": "http://example.org/doc", a node written"@id": ""and every reference to it came back as":base", in JSON-LD and in SPARQLBASEoutput. Each namespace now records whether it is a prefix, the vocabulary or the base. This predates the PR, andmainhas it too.@vocabas JSON-LD resolves it. Cypher (reads, writes and result names) and GraphQL's naming took the@vocabkey's text, so under a relative or compact-IRI@vocabneither found what a JSON-LD write stored. Both now askfluree-graph-json-ldfor the vocabulary.Breaking. The same document now writes different IRIs, and a context no longer reaches data an earlier release wrote under it.
compatibility.mdgets a breaking-change entry that names the shapes whose meaning changes, and a repair: where the stored IRIs are the ones meant, as under anhttp(s)vocabulary they usually are, write the/into the@vocaband change no data; otherwise three updates rename the properties, the types and the datatypes. I ran the updates against data in the shape an earlier release stored. A list on a renamed property loses its order, and the note says so.The W3C register. With #2396 on
next, these nine registered tests pass, and their entries are removed:t0075 was registered under JSON-LD 1.0 mode, but it failed because of the appended
/. Expand t0111/t0112 and toRdf te111/te112 now fail only on?query=works, so they move to the?group; te111/te112 also keep an invalid IRI, #2395's toRdf cause, which their entries note.compatibility.mdoverlap with #2400. #2400 adds its breaking-change section in the same place as this PR. Whichever lands second keeps both.Partially addresses #2395: this fixes the
@vocabpart of its IRI-expansion item. Relative@typevalues, terms that begin with:, and the refused term definitions remain.