Skip to content

Support for query variables #10

Description

@driesmarzougui

It's seems like query variables are not supported yet.

Example:

const Client = require('graphql-ld').Client;
const QueryEngineComunica = require('graphql-ld-comunica').QueryEngineComunica;

// Define a JSON-LD context
const context = {
    "@context": {
        "Film": "http://dbpedia.org/ontology/Film",
        "label": {"@id": "http://www.w3.org/2000/01/rdf-schema#label", "@language": "en"},
        "starring": "http://dbpedia.org/ontology/starring"
    }
};

// Create a GraphQL-LD client based on a client-side Comunica engine over 3 sources
const comunicaConfig = {
    sources: [
        {type: "sparql", value: "http://dbpedia.org/sparql"},
    ],
};
const client = new Client({context, queryEngine: new QueryEngineComunica(comunicaConfig)});

// Define a query
const query = `query MoviesActor($actor: String!){
          id @single
          ... on Film {
            starring(label: $actor) @single
          }
        }`;

const variables = {
    actor: "Angelina_Jolie"
};

// Execute the query
async function ex() {
    const data = await client.query({query: query, variables: variables});
    console.log(data);
}

ex();

Returns the following error:
Error: Undefined variable: actor

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions