Giter Site home page Giter Site logo

Comments (8)

yungsters avatar yungsters commented on May 8, 2024

Ahh... yes, I apologize greatly for not getting to this before we shipped yesterday. I'll try to get it fixed as soon as possible (unless someone beats me to it with a PR).

from relay.

devknoll avatar devknoll commented on May 8, 2024

@yungsters What's the ideal behavior? Would it be sufficient to just find the route.queries that includes a particular fragment and keep everything else the same?

from relay.

yungsters avatar yungsters commented on May 8, 2024

@devknoll Yes, I think that is the ideal behavior. Unfortunately, there is no good way of figuring out which queries in route.queries includes X when all we have to work with is ${Component.getFragment(X)}.

from relay.

devknoll avatar devknoll commented on May 8, 2024

Ok, two ideas.

  1. Super hacky: Run route.queries[y] with a mock component to find the fragment names it's looking for. Maybe parse the result to grab the type and make sure it matches on the component too.
  2. A little better: Modify the babel plugin to just stick the possible Xs as metadata on a route.queries[y]

Does one of these sound like an approach you'd take?

from relay.

yungsters avatar yungsters commented on May 8, 2024

Whoah, idea 1 is super hacky, but I like the way you think. ;)

Another more involved possibility is that we do something like what we did with RelayMutation#getName:

static queries = {
  user: () => Relay.QL`query { user(id: $userID) }`
};

The more I think about it, there really is no semantic value to the keys in queries. What if we got rid of ${Component.getFragment(X)} all together and made it clearer that the query name must match your component's fragment name?

I'm also curious what @josephsavona thinks about this.

from relay.

devknoll avatar devknoll commented on May 8, 2024

What if we got rid of ${Component.getFragment(X)} all together and made it clearer that the query name must match your component's fragment name?

I like this idea a lot. I like that it makes it more consistent with mutations and gets rid of the (seemingly arbitrary) Component argument, while making it clearer that the query name means something.

In either case, is there a reason we couldn't also just throw an invariant in there to make sure that that every fragment matches a route query? Maybe it'll save some other folks some time ;-)

from relay.

josephsavona avatar josephsavona commented on May 8, 2024

What if we got rid of ${Component.getFragment(X)} all together and made it clearer that the query name must match your component's fragment name?

Yes. We should do that, and also implement @devknoll's idea - root component fragments are automatically added whenever the route key matches the component key, and it's a warning/error if either one has a key that the other is missing.

from relay.

devknoll avatar devknoll commented on May 8, 2024

Solved by #181

from relay.

Related Issues (20)

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.