-
Notifications
You must be signed in to change notification settings - Fork 146
Create typedefs automatically by inferring GraphQL Schema from Neo4j #223
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is looking good - most simple cases seem to be handled :-)
I left a few comments, let me know what you think.
LocalDateTimeArray: '[LocalDateTime]' | ||
}; | ||
|
||
return mapping[t] || 'String'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes String
the default when a property type is not found in the above mapping object. This is a reasonable default, however, currently this causes problems in the case of a complex type, such as Point
, that exists in the database but cannot be serialized into a string properly by the GraphQL layer since it is treated as an object when returned by the Neo4j driver.
Should we instead exclude these properties from the type definitions? I think we could get away with this as is since Point
support will be added soon to neo4j-graphql-js, but are there other possible complex database types that aren't handled by neo4j-graphql-js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to be exhaustive on mapping potential neo4j types, but yeah I think I missed "Point".
I don't think we can get away with omitting "Points" though, becuase the auto-gen schema is going to get fed to augment, which will accept the omission I guess. Maybe we need a carve out and to omit those properties pending point support, but ultimately I guess I need some directive, or other way to express that it's a point so that augment can do the right thing. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this as-is then - with String as the default. And I can add Point to the inferSchema mapping once we support it in neo4j-graphql-js. I think Point is the only complex type not supported by neo4-graphql-js and we plan to add it very soon. So in the meantime Point fields will be treated as strings, I'm OK with that.
Thanks @moxious! This is a super cool feature! |
(Current status: blocked by needed resolution on #235 otherwise this is almost ready)
What this does
db.schema.nodeTypeProperties()
anddb.schema.relTypeProperties()
to harvest info about the graph structure. That information is then transformed into a GraphQL schema.Example Mapping
Given a simple graph schema like this:
We want in the end:
Design Notes & Decisions discussed with Will
_id
to all nodes.