rdf-dereference.js icon indicating copy to clipboard operation
rdf-dereference.js copied to clipboard

Allow users to pass Comunica context through the library

Open alexkreidler opened this issue 4 years ago • 1 comments

The RdfDereferencerBase passes options of type IDereferenceOptions to the cbrd:Bus/RdfDereference via the mediate function as the context.

See here: https://github.com/rubensworks/rdf-dereference.js/blob/645a126a632111163a1c6ad58f9c17c46c0b2de9/lib/RdfDereferencerBase.ts#L25-L30

Since the context exposes a variety of options for users to configure Comunica, such as an HTTP proxy for example, which is quite relevant to rdf-dereference, it makes sense for users to be able to provide the context to rdf-dereference.

That could be achieved by

  • Making IDereferenceOptions a broader type (e.g. extending it to include Record<string, any>) It would have to be that wide because not all context options are simple strings, some are functions or objects
  • Adding a separate context field to the IDereferenceOptions and passing that as the context to mediate

Of course, users could simply override Typescript to pass the context as they want currently as additional fields on the option argument, but this would make it explicit and indicate to users that it is a valid option.

alexkreidler avatar Nov 14 '20 23:11 alexkreidler

Good point! Option 1 seems like the most straightforward to me. (could also be applied to https://github.com/rubensworks/rdf-parse.js)

Feel free to submit a PR on this!

rubensworks avatar Nov 16 '20 13:11 rubensworks