Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Relay 2 #12

Closed
metacortex opened this issue Apr 21, 2017 · 21 comments
Closed

Support Relay 2 #12

metacortex opened this issue Apr 21, 2017 · 21 comments

Comments

@metacortex
Copy link

Hi.

Any plan to support Relay Modern?

I am big fan of found,
and looking forward to use the new relay with it.

@taion
Copy link
Member

taion commented Apr 21, 2017

Yeah, will update when I get a chance to wrap my mind around it all

@coleturner
Copy link
Contributor

coleturner commented May 8, 2017

Found is my favorite router and I looked into swapping out Relay classic with rudimentary modern support. One of the walls I ran into is that Pagination and Refetch containers do not expose the query that is used when creating the component for those containers. Therefore queries would (in that scenario) have to be manually exported and decoupled from the function calls: createPaginationContainer(..., thisQuery) instead of createPaginationContainer(..., graphql template literal here)

@taion
Copy link
Member

taion commented May 8, 2017

See facebook/relay#1687.

I'm not really planning to touch the pagination or refetch containers; instead my current plan is to have each route for Relay 2 act like a <QueryRenderer>, the way routes currently act like <Relay.Renderer>s.

@coleturner
Copy link
Contributor

coleturner commented May 13, 2017

Looking forward to seeing how it will work. Thanks again @taion!

I am currently upgrading an app to Modern Relay and intend to continue using Found, which is why I have forked found-relay have a crude working implementation with Modern Relay:

coleturner@73a9255

<Route
    Component={Container}
    initialVariables={{
      ...
    }}
    query={query}
  />

Where initialVariables can be either an object or function(route) and query is a GraphQL template literal.

@taion
Copy link
Member

taion commented May 20, 2017

@colepatrickturner

That's not quite optimal – since you're nesting <QueryRenderer>s, you'll end up firing off your queries serially.

I need to do an upstream change in Found to how element resolvers work to properly support concepts like leaving routes, in order to enable the proper GC behavior.

@rosskevin
Copy link

rosskevin commented May 31, 2017

I'm doing a big change in our apps, converting to found, found-relay, and moving everything to [email protected] (modern). I see that #17 was just merged. What is the status on relay 1.0 support, and is there anything I can do to help?

@taion
Copy link
Member

taion commented May 31, 2017

@rosskevin

If you just want to use react-relay/classic, see https://github.com/4Catalyzer/found-relay/tree/relay-1.

I'm going to merge that soon, but need to figure out release plans. I might cut a v0.2.x that supports a few minor Found API changes (https://github.com/4Catalyzer/found-relay/tree/relay-1) but still uses Relay v0.10.x, then cut a v0.3.x that supports Relay v1.x.

If you actually want to use the modern API with <QueryRenderer>, then I'm still a few days away from having something that works.

@rosskevin
Copy link

Thanks @taion - I'm looking to use the QueryRenderer version. Please ping me if I can help out.

@taion
Copy link
Member

taion commented Jun 1, 2017

Nope, I should have something up in a few days.

@taion
Copy link
Member

taion commented Jun 1, 2017

Thanks though!

@rosskevin
Copy link

rosskevin commented Jun 1, 2017

@taion Thank you!

I'm working on converting and getting all the code ready in the meantime (including a flow type libdef for found). It seems like the relay-compiler step for persisted queries e.g. relay-compiler --src ./src --schema ./schema.json may be at odds with the approach of putting a root query on a route. All of my relay-compiler errors are related to such root queries. Arguably, I'm a graphql novice so I may be missing something simple.

I'll be interested to see your approach in a todo modern example.

@taion
Copy link
Member

taion commented Jun 2, 2017

@rosskevin What error specifically are you seeing?

@rosskevin
Copy link

All on the root queries, relative to relay-todomvc we have one just like it:

import {graphql} from 'react-relay/compat'

export default {
  viewer: () => graphql`query ViewerQueriesQuery { viewer }`
}

The error will be:

Error: You supplied a GraphQL document with validation errors:
Field "viewer" of type "Viewer" must have a selection of subfields. Did you mean "viewer { ... }"?

@taion
Copy link
Member

taion commented Jun 2, 2017

See #27. https://github.com/4Catalyzer/found-relay/blob/relay-modern/test/modern/Resolver.test.js specifically demonstrates how to set up queries with Relay Modern.

@taion
Copy link
Member

taion commented Jun 3, 2017

Released as v0.3.0-alpha.1. See https://github.com/taion/relay-todomvc/tree/found-modern for an example.

@taion taion closed this as completed Jun 3, 2017
@taion
Copy link
Member

taion commented Jun 3, 2017

Note BTW there's no found-relay/lib/compat – at least, not yet. We're only just starting the move to Relay v1.x in our code base, so it hasn't come up yet. At the moment I'm not sure if it will.

@coleturner
Copy link
Contributor

Thank you @taion!

@Rodeoclash
Copy link

@taion Thanks for this, it's working pretty well. Can't figure out how to get the environment / relay object on the props but I'm sure it's something I'm missing and explained somewhere in the example app 😄

@taion
Copy link
Member

taion commented Jun 12, 2017

It's the same as if you're just using <QueryRenderer>s. Use like context.relay.environment or whatever.

@rosskevin
Copy link

@Rodeoclash here's a migration playbook to get to modern:
https://www.graph.cool/docs/tutorials/migrating-to-relay-modern-eijooto4se/

@Rodeoclash
Copy link

Rodeoclash commented Jun 13, 2017

Yeah, it was a silly mistake. createFragmentContainer will inject the relay object into the props. I was trying to access it through a component mounted by the router (which only has a query).

Either way, I construct the environment in a seperate module so can easily import into whatever component needs to do a mutation.

@rosskevin Thanks for the link

taion added a commit that referenced this issue Mar 19, 2019
f5f341e docs: Fix docs
ad96285 fix: Fix tooling
a6cab23 fix: Various bugfixes (#41)
5c7fb83 chore: Update dependencies (#30)
cc1085a more
5d616b2 chore: Update dependencies
76b9016 Update dependencies
aebfa93 Fix build
e6564fe Update dependencies
e5d1f40 Update dependency
ba4651a Update dependencies
80a966f Fix pattern
6a6abb9 Update dependencies
668f02a Downgrade graphql
57f77eb Merge branch 'found-modern'
4d2f7d8 Update dependencies
e6d4e86 Use Found Relay Modern
8634bba Merge pull request #21 from taion/update-readme
597aeef Add found-modern-universal [ci skip]
6d89772 Use Found Relay Classic
2394893 Merge pull request #20 from taion/update-README
b265b6f Update project naming in README [ci skip]
671f3c2 Merge pull request #19 from taion/update-README
cc249f3 Update README [ci skip]
1a86b11 Merge branch 'master' into found-classic
a15f5a1 Merge pull request #18 from taion/fix-readme
8b1f8a1 Remove wrong note in README
87bb04b Update for Found v0.3.x
317f4c1 Use Found
38a8dcc Merge pull request #17 from taion/upgrade-relay
c7fa52b Upgrade to Relay v1.x (not Relay Modern)
6b062cd Merge pull request #15 from taion/fix-dev-source-map
c690479 Fix dev source map
34ecfea Merge pull request #14 from taion/fix-webpack
59e36ec Fix webpack config
efef591 Merge pull request #13 from taion/fix
1ca22f1 More fixes
a30143f Merge pull request #12 from taion/update
fe44bef Update dependencies
0e4a1fd Merge pull request #11 from alexmcmillan/master
078b6b9 Updating links to official Relay TodoMVC application and license
ddfe02d Merge pull request #9 from taion/passPerPreset
36cb4ac Drop passPerPreset
3ef9ccb Merge pull request #8 from taion/fix-mutations
a8a424e Fix mutations
af2b8bc Merge pull request #7 from taion/update
76c1194 Update everything to newest
76c527a Upgrade react-router-relay
73529e1 Move back to React Router
5a5dcbe Update checked-in schema
d4bba5d Update dependencies and move to rrtr (#6)
edb3dff Update for React Router v2.x
c7d70f6 Actually update the dumped schema
9174561 Fix limit to work with new graphql-js
a4a5247 Update dependencies
596184e Update dependencies
5025f9b Update dependencies
af2e837 Sync with upstream example
b21e481 Properly use IndexLink
281bdd9 Update dependencies
4976138 Clarify how to access local example
1170d76 Update copy a bit
ebd36b9 Need babel-runtime too
278cb42 Properly pin react-router dependency
b7fcac6 Update README.md
cf34189 Fix build script
b2d8970 Update README.md
49b9545 Add missing dependency
b65227b Update README.md
bdd98cb Implement TodoMVC
09d5ca3 Initial commit
REVERT: 437ff9c Squashed 'examples/todomvc-modern/' changes from aebfa93..76b9016
REVERT: 3386e8f Squashed 'examples/todomvc-modern/' changes from e5d1f40..aebfa93
REVERT: 78930fa Squashed 'examples/todomvc-modern/' changes from 80a966f..e5d1f40
REVERT: 953911e Squashed 'examples/todomvc-modern/' changes from 6a6abb9..80a966f
REVERT: d9083b4 Squashed 'examples/todomvc-modern/' changes from 668f02a..6a6abb9
REVERT: 24d38a4 Squashed 'examples/todomvc-modern/' changes from e6d4e86..668f02a
REVERT: bc74832 Squashed 'examples/todomvc-modern/' content from commit e6d4e86

git-subtree-dir: examples/todomvc
git-subtree-split: f5f341e34fc98380c6ea7c12be394ad813568164
taion added a commit that referenced this issue Mar 19, 2019
433892f Merge branch 'found-modern' into found-modern-universal
f5f341e docs: Fix docs
ad96285 fix: Fix tooling
22a3af9 fix: Fix network layer
6e057a1 Merge branch 'found-modern' into found-modern-universal
a6cab23 fix: Various bugfixes (#41)
51270b1 Merge branch 'found-modern' into found-modern-universal
5c7fb83 chore: Update dependencies (#30)
cc1085a more
5d616b2 chore: Update dependencies
1c103e3 Merge branch 'found-modern' into found-modern-universal
76b9016 Update dependencies
cd6b3f1 Merge branch 'found-modern' into found-modern-universal
aebfa93 Fix build
73c5c83 Update `found-modern-universal` example app with `relay-network-modern` (#28)
1260aab Merge branch 'found-modern' into found-modern-universal
e6564fe Update dependencies
e5d1f40 Update dependency
2bd7b54 Merge branch 'found-modern' into found-modern-universal
ba4651a Update dependencies
ae69ae5 Merge branch 'found-modern' into found-modern-universal
80a966f Fix pattern
59254ab Use hydrate instead of render
3b5fd9a Merge branch 'found-modern' into found-modern-universal
6a6abb9 Update dependencies
d6d2397 Merge branch 'master' into found-modern-universal
668f02a Downgrade graphql
57f77eb Merge branch 'found-modern'
4d2f7d8 Update dependencies
8efad95 Relay Modern with server-side rendering
e6d4e86 Use Found Relay Modern
8634bba Merge pull request #21 from taion/update-readme
597aeef Add found-modern-universal [ci skip]
6d89772 Use Found Relay Classic
2394893 Merge pull request #20 from taion/update-README
b265b6f Update project naming in README [ci skip]
671f3c2 Merge pull request #19 from taion/update-README
cc249f3 Update README [ci skip]
1a86b11 Merge branch 'master' into found-classic
a15f5a1 Merge pull request #18 from taion/fix-readme
8b1f8a1 Remove wrong note in README
87bb04b Update for Found v0.3.x
317f4c1 Use Found
38a8dcc Merge pull request #17 from taion/upgrade-relay
c7fa52b Upgrade to Relay v1.x (not Relay Modern)
6b062cd Merge pull request #15 from taion/fix-dev-source-map
c690479 Fix dev source map
34ecfea Merge pull request #14 from taion/fix-webpack
59e36ec Fix webpack config
efef591 Merge pull request #13 from taion/fix
1ca22f1 More fixes
a30143f Merge pull request #12 from taion/update
fe44bef Update dependencies
0e4a1fd Merge pull request #11 from alexmcmillan/master
078b6b9 Updating links to official Relay TodoMVC application and license
ddfe02d Merge pull request #9 from taion/passPerPreset
36cb4ac Drop passPerPreset
3ef9ccb Merge pull request #8 from taion/fix-mutations
a8a424e Fix mutations
af2b8bc Merge pull request #7 from taion/update
76c1194 Update everything to newest
76c527a Upgrade react-router-relay
73529e1 Move back to React Router
5a5dcbe Update checked-in schema
d4bba5d Update dependencies and move to rrtr (#6)
edb3dff Update for React Router v2.x
c7d70f6 Actually update the dumped schema
9174561 Fix limit to work with new graphql-js
a4a5247 Update dependencies
596184e Update dependencies
5025f9b Update dependencies
af2e837 Sync with upstream example
b21e481 Properly use IndexLink
281bdd9 Update dependencies
4976138 Clarify how to access local example
1170d76 Update copy a bit
ebd36b9 Need babel-runtime too
278cb42 Properly pin react-router dependency
b7fcac6 Update README.md
cf34189 Fix build script
b2d8970 Update README.md
49b9545 Add missing dependency
b65227b Update README.md
bdd98cb Implement TodoMVC
09d5ca3 Initial commit
REVERT: b76ab0f Squashed 'examples/todomvc-modern-universal/' changes from cd6b3f1..1c103e3
REVERT: d83d5db Squashed 'examples/todomvc-modern-universal/' changes from 2bd7b54..cd6b3f1
REVERT: 6ff12fe Squashed 'examples/todomvc-modern-universal/' changes from ae69ae5..2bd7b54
REVERT: 0da779c Squashed 'examples/todomvc-modern-universal/' changes from 59254ab..ae69ae5
REVERT: 9d6fdd1 Squashed 'examples/todomvc-modern-universal/' changes from d6d2397..59254ab
REVERT: c1b5604 Squashed 'examples/todomvc-modern-universal/' changes from 8efad95..d6d2397
REVERT: f57793f Squashed 'examples/todomvc-modern-universal/' content from commit 8efad95

git-subtree-dir: examples/todomvc-universal
git-subtree-split: 433892f4b2c9ef2fc251f2647d6c6db8e6df7304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants