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
Uh oh!
There was an error while loading. Please reload this page.
-
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
Personcalledvehicle_idand hardcoding it in thePeople.tsschema 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
idandrelatedField.If the Vehicle Entity has an
idfield and avh_idfield, and the Person Entity has avehicle_idfield, how would I use theseidandrelatedFieldproperties 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
fetchfunction 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:
idandrelatedFieldproperties?Beta Was this translation helpful? Give feedback.
All reactions