Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-29-2021 08:37 AM
Hello everybody,
I am a software ingineer working with the INRAE (National French Institute for agroecologics) and i am willing to integrate a neo4j database to handle ontology driven data.
I am currently prototyping a appollo graphql CRUD using neo4j-graphql to handle the cumbersome work, and everything seems to be encouraging if for one thing:
When using ontologies (but it is easily find in any buisness logic...), we have inheritance between concept (directly infered from owl:subClassOf property).
I don't succeed to make the generated (mutation) resolvers to understand what seems to be a logical deduction, which is to put more than one label on the created nodes. To be more precise, i generate the gql from the parsed ontology, and i tried three approaches:
I defined all classes as interface, then implements one or many of them as type. I expected all the interfaces as labels, as well as the type itself => the created node only has the type as label
I tried to use union type, but the appollo server throw an error of *"union_type" defined in resolvers, but not in schema
I overloaded mutation query with a cypher statement looking like "@cypher(
statement: """
CREATE (a:Dog:Animal {name: $name})
RETURN a
"""
)"
and, while this works, I will then need to properly rewrite all the creation mutation. I guess it is doable, but I am a bit wimpy at doing this, as the purpose of using cypher-neo4j is preciseley to avoid doing that kind of cumbersome work...
I also find possible resolution of this problem on forum using Graphql Architect, but this seems too conected to the neo4j desktop, and i would prefer a more "scripty" approach.
In particular, this topics
and this one talk about the same things, but starting from the neo4j graphql get started setup, I could not make it work ("_" notation or interface solution)
Does anyone knows where I could find some help ?
Thank you for reading this,
Guilhem
11-30-2021 08:59 AM
I got an answer on the discord. Through I did'nt get success searching online, I'll post the answer here, in case it can helps someone else.
So the "atomic" problem was something like
interface Animal {
name: String!
}
type Dog implements Animal {
name: String!
is_fed: Boolean
}
and the solution was
interface Animal {
name: String!
}
type Dog implements Animal @node(additionalLabels: ["Animal"]) {
name: String!
is_fed: Boolean
}
The change from the neo4j-graphql-js package (deprecated) for handling "heredity" is by design.
Hope that helps, and thanks again to the community !
All the sessions of the conference are now available online