Did you know ... | Search Documentation: |
Predicate graphql_execute_document/4 |
Document is a Prolog term representing the abstract syntax tree of the GraphQL document, as obtained from e.g. graphql_read_document/3 or graphql/4 quasi-quotation. Result is unified with a dict representing the JSON formatted response received from the server.
The following example shows how graphql_execute_document/4 can be used to expose a simple GraphQL interface to Prolog:
sourcehut_repository_description(Owner, Repo, Desc) :- graphql_execute_document("https://git.sr.ht/query", {| graphql(Owner, Repo) || { user(username: <Owner>) { repository(name: <Repo>) { description } } } |}, Dict, [token(...)]), Desc = Dict.get(data/user/repository/description). ?- sourcehut_repository_description("eshel", "sourcehut.pl", Desc). Desc = "SWI-Prolog package implementing a SourceHut GraphQL API client.".
Options is a list whose elemenets are one of the following:
$key
.
Variables is sent to the remote to the GraphQL endpoint in
JSON format for server-side interpolation.
For more information about GraphQL variables, see
https://spec.graphql.org/draft/#sec-Language.