nelson-ai / semantic-graphql

Create GraphQL schemas from RDF ontologies
MIT License
28 stars 4 forks source link

How to iterate over all the types? #5

Open martinheidegger opened 7 years ago

martinheidegger commented 7 years ago

First off, it seems like you did exactly what I wanted to do, nice work.

However, I am slightly confused: I would like to be able to get all types of a RDF definition and turn them into GraphQL types: (I.e. I would like to turn http://imi.ipa.go.jp/ns/core/Core231.html into a GraphQL spec following the https://en.wikipedia.org/wiki/SPARQL definition). I havn't found a way to do that properly? Is this supported?

dherault commented 7 years ago

Hi,

This library can help you create GraphQLObjectTypes and GraphQLInterfaceTypes for all the classes listed in your first link. To do that you'll need the triples for your ontology (maybe there's a download link somewhere, I can't read Japanese). If you manage to find a turtle (.ttl) file containing your ontology then you can follow the examples (in examples folder). Otherwise you can still add your triples manually (with the addTriplemethod).

I don't understand what you want to achieve using SPARQL. If you want to fetch your data using SPARQL, then your can write your SPARQL queries in your "resolvers" (see the docs). By doing that, you are just transforming a SPARQL endpoint into a GraphQL endpoint.

martinheidegger commented 7 years ago

I would like to turn a given SPARQL API (a few endpoints) into a GraphQL APi endpoint. Thank you for your hints. I will look into them. (bedtime now, sadly)