RDF in Graphql in javascript


#1

Please i want your help ,

I spent a lot of time searching and asking, but I didn’t get an answer

I hope for help

I have a problem with my project GraphQl in javaScript

that I want to link a file RDF with my code in GraphQl in javascript

But i didnt find the solution to do that

then i think to convert RDF to json file is the solution

also i didnt find the solution to do that

then i found your project GraphQl

but it hard for my to implementation how i can creatin schema
and the problem when in put console.log(data) is undefined
this is my code

const {Client} =require(“graphql-ld”);
const {QueryEngineSparqlEndpoint} =require(“graphql-ld-sparqlendpoint”);
const express = require(‘express’);
const graphqlHTTP = require(‘express-graphql’);
const cors = require(‘cors’);
require(‘top-level-await’);

// Define a JSON-LD context
const context = {
@context”: {
“label”: { “@id”: “http://www.w3.org/2000/01/rdf-schema#label” }
}
};

// Create a GraphQL-LD client based on a SPARQL endpoint
const endpoint = ‘http://dbpedia.org/sparql’;
const client = new Client({ context, queryEngine: new QueryEngineSparqlEndpoint(endpoint) });

// Define a query
const query = query @single { label };

// Execute the query

const{ data } = (async function() {
await client.query({ query });
console.log(data);
}());

const app = express();
app.use(
‘/graphql’,
graphqlHTTP({
schema:{ data },
graphiql: true
})
);

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(Server started on port ${PORT}));

please just i want ,you tell my how i can do what i want

in simple way


#2

You might want to post this question in the respective projects, such as the project for GraphQL-LD.


#3

the code in my question is the project GraphQL-LD but it not work well
because when you put console.log(data] is undefined as well client

I sent a message to Ruben Taelman
asked him bout this error but did not answer