-
Notifications
You must be signed in to change notification settings - Fork 147
Conversation
Update to upstream
upstream update
@michaeldgraham nice. A clean and semantically clear implementation. (Disclaimer: I haven't tried it yet...) But I do have two thoughts. First, why complicate things with the Second, it's confusing to use the same name as the field directive |
Thanks! I’m still working on some tests and trying to put together some more information on this PR’s post :) A lot of the SDL inspiration comes from @jexp's comment on this post: neo4j-graphql/neo4j-graphql#51 :) Nothing was done away with, the I have worried about directives maintaining consistency of metadata representation. So for now, because the metadata is the same as the existing ‘relation’ field directive (at least, the name argument remains), I kept the type directive named ‘relation’. That way, representation of Neo4j relationship metadata by directives is semantically consistent. It seems the ambiguity here is that the 'relation' directive can now be on both fields and types, but I think the structural difference built into fields vs types is enough there — I’ve gotten used to that, though. This is just the way I feel about it. Maybe in the future we could make directive names configurable. Also, if we introduce a |
This contains initial support for using relation types with managed directional fields
from
andto
, along with an optional@relation
type directive (should resolve #26 and #97).Input types are now generated in the schema augmentation process and used for
from
andto
node selection arguments in a new relation mutation API (should resolve #102).On a related note, relation mutations are now generated for
@relation
fields with the IN direction (#98).A relation type is a type with both a
from
field and ato
field. Any type with either but not the other will throw an error in the schema augmentation process.Example types:
If a type has both a
from
field and ato
field but no@relation
directive is provided, then one is generated. In that case, or if you write a@relation
type directive but provide noname
argument, then a default relation name is created for you, equal to a transformation of the relation type name (rated
intoRATED
,FriendOf
intoFRIEND_OF
, etc.).If you choose to use such a default name, then you can omit the
@relation
directive:Relation Query API
During the schema augmentation process, the
from
andto
fields on relationtypes are transformed to be equal to their type values. This is done in the hopes of making nested queries more semantic.
Relation Mutation API
While the use of relation types is optional, the relation mutation API has changed generally to include input types for
from
andto
arguments. Add and remove relation mutations are still generated for@relation
fields, but they use thefrom
andto
argument format in order to keep the relation mutation API consistent and provide a bit more structure.Relation mutation payload types are also generated in order to make the return selection format consistent with the
from
andto
arguments.Relation mutations generated for the
rated
field of thePerson
type:AddPersonRated
If there are no fields other than
from
andto
on a relation type (see below), the add relation mutation will not have adata
argument, making it identical to the add relation mutation normally generated for a@relation
field.RemovePersonRated
Similar relation mutations would be generated for the
ratings
field of theMovie
type.