Coder Social home page Coder Social logo

Comments (9)

jean-leonco avatar jean-leonco commented on June 1, 2024 1

The problem seems to be on client. Using the curl on terminal, the information was returned.

image

The problem has to do with client, probably in the way that information is provided to children

from foton-mobile.

jgcmarins avatar jgcmarins commented on June 1, 2024

why?
could be related to data mask
could share piece of code or link?

how is the result from the query?

from foton-mobile.

jean-leonco avatar jean-leonco commented on June 1, 2024

Here is the root query of App when authenticated:

const isAuth = true;

  const Routes = createRouter(isAuth);

  if (isAuth) {
    const Root = () => {
      const query = useQuery(graphql`
        query AppQuery {
          ...Dashboard_products
        }
      `);

      return <Routes />;
    };

    const RootWrapper = () => {
      return (
        //@ts-ignore
        <ErrorBoundaryWithRetry
          fallback={error => <ErrorScreen error={error.message} />}
        >
          <React.Suspense fallback={<LoadingScreen />}>
            <Root />
          </React.Suspense>
        </ErrorBoundaryWithRetry>
      );
    };

    return <RootWrapper />; 

Relay finds the fragment and send requisition to server.
image

But the const that receive useFragment, products appears as null.

const products = useFragment(
    graphql`
      fragment Dashboard_products on Query {
        products(first: 10) @connection(key: "Dashboard_products") {
          edges {
            node {
              id
              name
              description
            }
          }
          pageInfo {
            hasNextPage
            startCursor
          }
        }
      }
    `,
    props.products,
  );

from foton-mobile.

jgcmarins avatar jgcmarins commented on June 1, 2024

try to copy the curl from network tabe
and test it through terminal
if there is no data, the problem is on backend
if there is data, the problem is on client

from foton-mobile.

jgcmarins avatar jgcmarins commented on June 1, 2024

nice
how can we debug it on client?
which methods of relay-experimental are you using?
do you have any link to the code where this problem is happening?

from foton-mobile.

jean-leonco avatar jean-leonco commented on June 1, 2024

I am using useQuery. In the relay-examples-hooks repo, I saw the UseLazyLoadingQuery, but it didn't come with relay-experimental. Could that be the issue?
The parts of the code where this problem is coming from are use Fragment and UseQuery.
I think the best way to debug is focusing on the useFragment hook. Sometimes that warning shows and sometimes it doesn't show.

from foton-mobile.

jgcmarins avatar jgcmarins commented on June 1, 2024

the problem is data masking:
data asked by the fragment won't be available on it's parent

this is a relay feature

components have access to the data they ask for and that's it

from foton-mobile.

jean-leonco avatar jean-leonco commented on June 1, 2024

But how could we have access to data? Since here the root component won't have the information.

from foton-mobile.

jgcmarins avatar jgcmarins commented on June 1, 2024

colocation
each component ask for the data they will use
a component should not ask for data that won't be used

from foton-mobile.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.