Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for query variables #10

Open
driesmarzougui opened this issue Aug 7, 2019 · 1 comment
Open

Support for query variables #10

driesmarzougui opened this issue Aug 7, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@driesmarzougui
Copy link

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

@rubensworks
Copy link
Owner

Thanks for reporting!

Note to self: there's a big TODO for that here: https://github.com/rubensworks/GraphQL-LD.js/blob/master/lib/Client.ts#L75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants