semantic-graphql
semantic-graphql copied to clipboard
More examples and documentation
hey everyone,
I am trying to adapt https://github.com/dherault/aquest to use schema.org ttl files but I am not sure how to make that work. also printSchema just return:
"""An object with an ID"""
interface Node {
"""The id of the object."""
id: ID!
}
type Query {
"""Fetches an object given its ID"""
node(
"""The ID of an object"""
id: ID!
): Node
}
not sure if it is the correct output.
when I start the service, the output is:
graph created: [SemanticGraph: 6099 triples]
GraphQL endpoint listening on port 3001
You need an entrypoint in your schema. Can your paste your schema file ? It should be a bit like this:
const schema = new GraphQLSchema({
node: nodeField,
person: personField,
})
where person: personField is your entry point. personField should be of type Person, found in the graph.
currently my schema is just:
module.exports = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
// Relay's favorite
node: _.nodeField,
// Helpers for common app resources
// Viewer's data entry point
/*
viewer: {
resolve: (source, args, { viewer }) => viewer,
},*/
},
}) /*,
mutation: new GraphQLObjectType({
name: 'Mutation',
fields: mutationFields,
}),*/
});
is there a way add this entrypoints automatically from rdf? schema.org has a lot of entities/types ....
Well you could modify your schema like this:
module.exports = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
// Relay's favorite
node: _.nodeField,
// Helpers for common app resources
// Viewer's data entry point
/*
viewer: {
type: _.getObjectType('http://schema.org/Person'),
resolve: (source, args, { viewer }) => viewer,
},*/
},
}) /*,
mutation: new GraphQLObjectType({
name: 'Mutation',
fields: mutationFields,
}),*/
});
The type http://schema.org/Person will insert in your schema all the triples relative to Person, including its super classes.
Have a look at the examples folder for more info.
yes I have look that. I could add manually types like Dataset and Person .. but not sure yet how to add all fields automatically.
I am playing with that here: https://github.com/Quansight/ivan-sandbox/blob/master/semantic-graphql-test/service/src/schema.js
To add all fields automatically, you'll have to iterate on all your classes and add a field for each class. Or you can add this entrypoint:
resource: {
// The rdfs:Resource interface allows you to query any data
type: _.getInterfaceType('http://www.w3.org/2000/01/rdf-schema#Resource'),
args: {
id: { type: new GraphQLNonNull(GraphQLString) },
},
resolve: /* ... */,
},
thanks @dherault I will try that!