When using GraphQL and Relay and Fragment, how to see the data?

When using GraphQL and Relay and Fragment, how to see the data?


0

I am onto Step 4 of the Relay Tutorial at: https://relay.dev/docs/tutorial/fragments-1/

It was strange because when I don’t use Fragment, and have the following code:

  const data = useLazyLoadQuery<NewsfeedQueryType>(
    NewsfeedQuery,
    {}
  )

  console.log("HERE 1", JSON.stringify(data, null, 4));

I was able to see in the dev console for the data:

HERE 1 {
    "topStory": {
        "title": "Local Yak Named Yak of the Year",
        "summary": "The annual Yak of the Year awards ceremony took place last night, and this year's winner is none other than Max, a beloved yak from the small town of Millville. Max, who is known for his friendly personality and hardworking nature, ...
  ...       

However, once I started using Fragment and useFragment, the same console.log of data does not have any content of:

The annual Yak of the Year awards ceremony took place last night

I wonder why the summary disappeared, yet it was able to work the same as before and have it shown on the webpage. I know fragment data is "hidden" or "masked" by Relay, but even if it is hidden, it should still be inside of data, shouldn’t it? By what way can I see it using a console.log()?

One possible way I am thinking is, could Relay be hiding all the fragment data by way of a function (or functions) inside of data and it does the returning the data? This way, console.log() won’t be able to print it out.


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *