LinkedSoftwareDependencies / Components.js

🧩 A semantic dependency injection framework
https://componentsjs.readthedocs.io/
Other
41 stars 6 forks source link

Long version of parameter doesn't work #125

Closed pheyvaer closed 1 year ago

pheyvaer commented 1 year ago

Issue type:


Description:

The following snippet doesn't work. It seems that no WaterfallHandler:_handlers are found.

"RepresentationConvertingStore:_options_outConverter": {
  "@type": "WaterfallHandler",
  "comment": "Set default output to ICS.",
  "WaterfallHandler:_handlers": [
    {
      "@id": "my:JsonToIcsConverter"
    }
  ]
}

The following snippet where WaterfallHandler:_ is removed works.

"RepresentationConvertingStore:_options_outConverter": {
  "@type": "WaterfallHandler",
  "comment": "Set default output to ICS.",
  "handlers": [
    {
      "@id": "my:JsonToIcsConverter"
    }
  ]
}

Environment:

Crash log:

rubensworks commented 1 year ago

I guess this is a context import issue @joachimvh?

joachimvh commented 1 year ago

I told him to post here because I don't see why this shouldn't work and perhaps I was missing something about the syntax.

rubensworks commented 1 year ago

What does the context contain for handlers and WaterfallHandler?

pheyvaer commented 1 year ago

Not a 100% if this is want you are looking for, but

"WaterfallHandler": {
  "@id": "css:dist/util/handlers/WaterfallHandler.jsonld#WaterfallHandler",
  "@prefix": true,
  "@context": {
    "handlers": {
      "@id": "css:dist/util/handlers/WaterfallHandler.jsonld#WaterfallHandler_handlers",
      "@container": "@list"
    }
  }
},
rubensworks commented 1 year ago

Aha, the @list is the difference.

So when using handlers, the value is implicitly represented as an RDF list, while this is not the case when using WaterfallHandler:_handlers.

So if you want to use that syntax, you'll have to do something like this:

"RepresentationConvertingStore:_options_outConverter": {
  "@type": "WaterfallHandler",
  "comment": "Set default output to ICS.",
  "WaterfallHandler:_handlers": {
    "@list": [
      { "@id": "my:JsonToIcsConverter" }
    ]
  }
}
pheyvaer commented 1 year ago

Ok and is this a feature or a bug? 😄

rubensworks commented 1 year ago

The fact that you don't need @list in handlers is a feature indeed. If you don't want to use that shortcut, you'll have to use a more verbose way of creating an RDF list.

pheyvaer commented 1 year ago

Ok, got it!