CLARIAH / grlc

grlc builds Web APIs using shared SPARQL queries
http://grlc.io
MIT License
135 stars 32 forks source link

Internal Server with transform query decoration #313

Closed ecow closed 3 years ago

ecow commented 3 years ago

Is the transform query decorator broken?

It returns 500 Internal Server Error both in my local installation (docker grlc:latest connected with a blazegraph sparql endpoint) and in the the official example ( http://grlc.io/api-git/CLARIAH/grlc-queries/#/default/get_transform )

c-martinez commented 3 years ago

Hi @ecow -- yes that definitely looks like a bug. Thanks for reporting this, I will look into it.

c-martinez commented 3 years ago

It looks like transformations work, BUT...

Transformer always works with json, so it breaks when the content-type is not json. Granted, it should break in a more graceful way.

If you set the response content type to application/json it should work fine:

image

Does this work for you @ecow?

I'll leave his issue open, until more graceful handling of json content type is fixed.

ecow commented 3 years ago

Hi, @c-martinez . even if using header "Accept: application/json' , my test fails with the simple decoration:

#+ transform: {
#+     "label": "?label"
#+   }

Instead the decoration

#+ transform: {
#+     "label": "?label",
#+     "$anchor": "label"
#+   }

works well, producing something like:

[
  {
    "label": {
      "language": "it",
      "value": "string1"
    }
  },
  {
    "label": {
      "language": "it",
      "value": "string2"
    }
  }
]

Is "$anchor" mandatory?

I would like to produce just a simple structure like:

[ "string1", "string2" ]

How to do it ? (if possible)?

c-martinez commented 3 years ago

Yes, I think the $anchor is mandatory.

I'm not an expert on transformer syntax, but maybe check their documentation. Otherwise, perhaps @pasqLisena might be able to shed some light.

pasqLisena commented 3 years ago

Hi, yes the software requires an $anchor or an id field. You can eventually mark it in this way:

transform: {
    "label": "?label$anchor"
}
c-martinez commented 3 years ago

Hi @ecow -- I just wanted to check with you if @pasqLisena's suggestion helped you solve your problem and if I can close this issue?

ecow commented 3 years ago

Yes, you can close these issue but docs should be updated. Thank you.