-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add basic support for Union types. Solves #3 #4
base: master
Are you sure you want to change the base?
Conversation
and getGraphqlPolymorphicObjectType
Re @Astn, thanks for the PR, this is great. What about the following: if the range is an owl:unionOf or owl:intersectionOf, return RdfResourceInterface as a starting point for support. |
I'm looking at http://facebook.github.io/graphql/#sec-Fragments-On-Composite-Types and trying to get a the same behavior out of this graphql library. They have the example fragment fragOnUnion on CatOrDog {
... on Dog {
name
}
} Which is the exact use case I have if you replace CatOrDog with Agent. fragment fragOnAgent on AgentUnion {
... on Person {
name
}
} The owl definition looks like this: schema:agent
rdf:type owl:ObjectProperty ;
rdfs:comment "The direct performer or driver of the action (animate or inanimate). e.g. *John* wrote a book." ;
rdfs:domain schema:Action ;
rdfs:label "agent" ;
rdfs:range [
rdf:type owl:Class ;
owl:unionOf (
schema:Organization
schema:Person
) ;
] ; I think part of the problem we are dealing with is that schema:Orginization and schema:Person do not implement an "agent" interface. But that case is pervasive in schema.org.
So at least in this case where we have an ObjectProperty with a Range [ Union ] returning a RdfResourceInterface wont work for us, as the consumer of the API wont get any information about what could be returned, and would be forced to make a subsequent query directly for the concrete type they got a resourceID back for. That pushes type resolution back to the client increasing client complexity, and also significantly increasing latency and thus user experience. I agree that adding a big chunk of code for one feature can feel heavy handed, and I'm more then happy to take suggestions or find ways to simplify the solution. But I have to have a way to keep moving forward and have a solution that has our graphql API to supporting fragments over ObjectProperties that reference owl:UnionOf in an idiomatic graphql style. I'd love your suggestions on how to solve this problem in a way that works for both of us. |
This solves #3 Please review and let me know what kind of changes are needed.
The current behavior when dealing with a range of resources was to return an interface for Resource. The range was being ignored.
This pull request changes that behavior to now use the range of resources and return GraphQLUnionType with those resources as a part of the union.
This will break queries that previously pulled properties directly out of rdfsResource e.g.,
A migration path for the same behavior could be:
Additionally, the other types and interfaces from the Union should now be available e.g.,