entria / ReactNavigationRelayModern

React Navigation integration with Relay
173 stars 23 forks source link

remove Viewer #15

Closed sibelius closed 7 years ago

sibelius commented 7 years ago

depends on https://github.com/entria/graphql-dataloader-boilerplate/issues/46

ssomnoremac commented 7 years ago

@sibelius , what would this require? If you could provide a roadmap for this I could help. I'm starting again with Relay after a year and I've heard viewer is being depreciated.

sibelius commented 7 years ago

let me know if you need any help

ssomnoremac commented 7 years ago

Hey @sibelius . thanks! I'm using my own server/schema and just got it working, I'm using Absinthe but I'll see about a PR here and there when I get a chance. This starter has been a great help getting up to speed with Modern. The only snag I've had has been passing after: null to a non-js backend. But I think that's what the spec says so I'd rather not implement a work-around.

ssomnoremac commented 7 years ago

@sibelius , so is it UserList_me?

ssomnoremac commented 7 years ago

that doesn't make sense actually, shouldn't the type just be UserList? It's at the root so the users field is on directly on props, not nested. But since it has to be <module>_<prop> could we just expose it as UserList_data as data is the field at the root of the query?

sibelius commented 7 years ago

I think this could work

https://github.com/sibelius/ReactNavigationRelayModern/blob/master/src/UserList.js#L115

instead of

fragment UserList_query on Query

ssomnoremac commented 7 years ago

@sibelius , thanks, but I'm having a hard time with this one because I haven't used fragments in a while: so

 query: graphql`
      fragment UserList_query on Query{
        users( ...

then I have to do

query: graphql`
      query UserListPaginationQuery (
        $count: Int!,
        $cursor: String
      ) {
        ...UserList_query
      }

because there is no field query on Query; however, then there are no fields in the graphql response Object {__fragments: Object, __id: "client:root"}

sibelius commented 7 years ago

It is something like that, remember that Relay mask the data, only the component that asks for the data will see it this data

ssomnoremac commented 7 years ago

success! 🎉

Thanks, yes, I forgot that, but had my query={props.query} needed to be query={props}

Submitting PR!

sibelius commented 7 years ago

fixed here https://github.com/sibelius/ReactNavigationRelayModern/pull/18