Replies: 1 comment
-
Hey there, sorry for the slow response. I'll answer below: First off you'll want to always only have one property with a given name. In your example you've got two Here are the answers to your specific questions:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a multi part question that all relates to the same topic - I want to be able to Link Entities through a REST API - using the swapi as an example. I have been following this documentation: https://graphweaver.com/docs/linking-entities
I will be linking a Vehicle (or many Vehicles) Entity to a Person Entity.
I can link a single entity by creating a field in
Person
calledvehicle_id
and hardcoding it in thePeople.ts
schema file. However, I cannot assign it programmatically, as not every person has a vehicle, and thus there is an errorCannot return null for non-nullable field Person.veh
. Even if the field is assigned a blank string.Assigning multiple Entities does not work either as the GraphQL query turns up blank.
There is also some confusion around the use of
id
andrelatedField
.If the Vehicle Entity has an
id
field and avh_id
field, and the Person Entity has avehicle_id
field, how would I use theseid
andrelatedField
properties to force GraphWeaver to joinvehicle_id
(person) tovh_id
(vehicle)?As It would appear,
relatedField: 'vehicle_id'
only joinsvehicle_id
(from the person entity) toid
(of the vehicle entity)Another thing I noticed is that GraphWeaver is calling the Vehicle Entity for each Person. That is; if I hardcode each person (say 83 people) to have a single vehicle (the Snowspeeder with id:14), the
fetch
function from the Vehicle Entity schema file, is called 165 times. Is this intended behaviour? If not, how do we write the linked entities such that their information is only fetched when required - i.e. a REST call that uses parameters, such as the vehicle ID?Questions:
id
andrelatedField
properties?Beta Was this translation helpful? Give feedback.
All reactions