Hi,
Newbie here. We have a project using Dgraph, and the schema is written in GraphQL± (I believe).
Is there a way to incorporate the concepts of RDF domain and range, into our schema? If there is a Dgraph doc on this, that would be fine to link to. I did try to search for one, and search the forum here, but could not find anything.
Yes, that’s the core concept I was getting at. In both directions (domain/range) I just know that rdfs:domain and rdfs:range is a thing, but I don’t necessarily want to use rdf. Is there something (close to) “equivalent” to that in graphql± / Dgraph?
Thank you!
EDIT: To expand a bit, is there something that can be done in the schema (graphQL±) to enforce such constraints? I’m not 100% sure if that question even makes sense. But basically like you posed it: when someone goes to input data into our schema, how do we define in the schema to constrain the the types that the user is trying to link, to not be the incorrect type, in the sense of rdfs:domain and rdfs:range ?
@leka0024 That’s an interesting use-case. I haven’t encountered this before though, but at some place we do check the validity of schema with respect to data in field I suppose. What I mean is if you schema specifies string but you pass in an integer then either it type-casts or throws. Let me look around and get back to you. Thanks!
in particular, for domain it notes (and gives an example):
An rdfs:domain axiom asserts that the subjects of such property statements must belong to the class extension of the indicated class description.
similar for range (right beneath).
Really what we want, like in the toy example, is to prevent someone else, who is putting in data to the ontology schema to create an instance, from incorrectly linking the various types of sub-classes/objects. It shouldn’t be allowed to link a Car object to Michael, via the owns_pet property. That type of thing.
Does Dgraph have this type of constraining ability? Thank you!
I think another way to implement edge constraint would be to extend types package in dgraph. See here where we impose restrictions on primitive types while converting from string to respective types mentioned in the schema. Imposing a condition which checks for dgraph.type is a possible solution.
@leka0024 I wanted to put on note the research I did around adding such constraints. You are welcome to take a stab at it, though I feel it would require significant time investment if not familiar with the dgraph code base already.
@Anurag Thanks for the clarification. I don’t have the time or skill necessary to help with the development.
FWIW, I think these edge type constrains would be hugely useful for ontology designers. I’m surprised no one has asked for this before. Please consider if you can prioritize this feature development, if it doesn’t eat up too much resources. Thank you!
No worries! Thanks for bringing this issue to light. @MichelDiz has already created a ticket. We will update you on this thread once we get time to work on it. Feel free to raise more questions and discussions around here.
I’m pretty interested on ontology users using Dgraph to do so. Whenever you can share your experiences with Dgraph + ontology. There are some users who have given up because we don’t have a specific standard/tips for people on how to use ontologies in Dgraph. But there are definitely people in the community who are interested, they just don’t have the time.
One more question: would the interface and type ___ implements ___ be able to be “stacked”, implementing a hierarchy of object/class and sub-object/sub-class? Like for example, top level class of “Transportation”, then a sub-class of “Vehicle”, then sub-classes “Car” and “Truck” ?
Are you uploading the schema via GraphQL client also which endpoint are you hitting? Ratel would not work anymore. You should submit the schema to localhost:8080/admin/schema. See step 2 here. Queries and Mutations should go to localhost:8080/graphql
No, since earlier you were defining the types in GraphQL±. Now you should follow GraphQL syntax
Hi again @Anurag , thank you for the very prompt reply!
Unless there is a GUI for uploading (like Ratel), or it can follow the dgraph live command somehow, then I don’t know how to upload the schema. When I tried to navigate to localhost:8000/graphql it shows (Asset not found for path graphql) . EDIT: and same (Asset not found for path admin/schema)
I’m trying to think if this will still even work for us.
Say we have an object like “Travel Itinerary”. It needs a transportation object linked to it. Within that object, it needs option for vehicle (like someone driving something themselves) or riding (like someone paying for a ride on some type). Then each of these can be linked to sub-objects, eg Car, Truck, Van in the first, and Bus, Plane, Boat, etc. in the second.
Does this make sense? And we need to prevent someone linking some other type of object when inputting data, like a warehouse location.