Hello, I have tried to fetch some data from REST end point:
deliver.kenticocloud.com/975bf280-fd91-488c-994c-2f04416e5ee3/items/
I was able to set up the query and fetch the data (seeing the request when sniffing network):
https://github.com/Simply007/apollo-link-rest/tree/master/examples/apollo2
But when I am about to render the actual content, I do not have initialized the data:
https://github.com/Simply007/apollo-link-rest/blob/master/examples/apollo2/src/Components/Article.js#L26
Do you have an hint how to fix that.
I am also getting an error in console:
writeToStore.js:111 Missing field __typename in {
"item": {
"system": {
"id": "117cdfae-52cf-4885-b271-66aef6825612",
"name": "Cof
To run the example, just go the /examples/apollo2 and run:
npm install
npm run
Example is based on create-react-app script.
Hi @Simply007! I took a look at your API and example app. And I think you're missing a couple details in there.
You probably want to pass type: "MyType"
to your @rest()
directive call!
Because you have a deeply nested object structure, you may also want to take a look at typePatcher
https://github.com/apollographql/apollo-link-rest/blob/75df172a028148a75daa4764c0a81d6f10ddaf69/src/restLink.ts#L91-L98
Cheers!
OK, if i get it right, you need to specify the format of the data you get from the rest.
To do that, it is required to set up TypePatcherTable to know the type "MyType" and then to the rest definition set this type.
Do you have any example, how to define the type using TypePatcherTable? Ideally with the type nesting.
Look for typePatcher in tests/restLink.ts, we have a complex nested example in there.
(I’m on my phone or I would give you a deep link to there, sorry!)
https://github.com/apollographql/apollo-link-rest/blob/76a0e47e41a207db29dbaf862ee83f97f495ea92/src/__tests__/restLink.ts#L377-L559
@Simply007 -- this is a complex example showing all the different ways you could set up typePatcher
Great, this is exactly what I need! :-)
Most helpful comment
https://github.com/apollographql/apollo-link-rest/blob/76a0e47e41a207db29dbaf862ee83f97f495ea92/src/__tests__/restLink.ts#L377-L559
@Simply007 -- this is a complex example showing all the different ways you could set up
typePatcher