No suggestions
Closed this issue · 4 comments
Whatever source I use, the results are always empty:
{"suggestions":[]}
I've added some logging src/Suggester/NdeTermsSuggest.php in the pareResult function and see that this function gets as $result:
Array
(
[data] =>
[errors] => Array
(
[0] => Array
(
[message] => Cannot read properties of undefined (reading 'operationName')
)
)
)
The message seems to be the result of the GraphQL query (on https://termennetwerk-api.netwerkdigitaalerfgoed.nl/graphql):
query FindTerm {
terms(
sources: ["http://data.bibliotheken.nl/thesp/sparql"],
query: "andri",
queryMode: OPTIMIZED)
{
source {
name
}
result {
... on Terms {
terms {
uri
prefLabel
altLabel
scopeNote}
}
... on Error {
message
}
}
}
}
When I run this query via https://termennetwerk-api.netwerkdigitaalerfgoed.nl/graphiql I do get results.
So my guess is, that the request via Laminas HTTP somehow is wrong
I found a solution:
if I replace this line with ->setRawBody(json_encode(['query' => $query]))
, and add ->setMethod('POST')
, I do get results again from the GraphQL API.
@ddeboer has the GraphQL API of the NoT become stricter? Did the API ever support the GET method?
Apparently GET requests were broken in netwerk-digitaal-erfgoed/network-of-terms#1059 due to Eomm/mercurius-logging#22.
While the GraphQL spec allows both GET and POST requests, POST requests are much more commonly used. So eb5864c is a good change.
Fixed in release 1.0.1