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

Nested queries #89

Closed
ksmth opened this issue Dec 28, 2015 · 3 comments
Closed

Nested queries #89

ksmth opened this issue Dec 28, 2015 · 3 comments

Comments

@ksmth
Copy link

ksmth commented Dec 28, 2015

const messagesQueries = {
  me : () => Relay.QL`query { me }`
};

const inboxQueries = {
  me : () => Relay.QL`query { me }`
};
<Route
  path="/org/:orgId"
  getComponent={(location, callback) => require.ensure([], require => {
    callback(null, require('./Messages'));
  })}
  queries={messagesQueries}
>
  <Route path="inbox">
    <IndexRoute
      queries={inboxQueries}
      getComponent={(location, callback) => require.ensure([], require => {
        callback(null, require('./InboxList'));
      })}
    />
  </Route>
</Route>
// InboxList Fragments
fragments : {
  me : () => Relay.QL`
    fragment on Account {
      organizations {
        id,
        savedThreadQueries {
          id
        }
      }
    }
  `
}
// Messages Fragments
fragments : {
  me : () => Relay.QL`
    fragment on Account {
      organizations {
        id
      }
    }
  `
}

Using this setup, the generated query looks something like this:

query Routes {
  me {
    id,
    ...__RelayQueryFragment0wpqdoa
  }
}

fragment __RelayQueryFragment0wpqdoa on Account {
  id,
  organizations { id }
}

But I think it should look like

query Routes {
  me {
    id,
    ...__RelayQueryFragment0wpqdoa
  }
}

fragment __RelayQueryFragment0wpqdoa on Account {
  id,
  organizations { id, savedThreadQueries { id } }
}

I don't know if I'm just using it wrong or what else might be happening that I don't understand properly yet.

@taion
Copy link
Member

taion commented Dec 28, 2015

That's just what Relay does when you have multiple queries. Not really anything to do with any code here.

@taion taion closed this as completed Dec 28, 2015
@NevilleS
Copy link
Contributor

His issue is that the resulting query doesn't appear to be pulling in the fragment requested by the InboxList. I'd expect the generated query to contain two fragments (one for Messages, one for InboxList), right?

@taion
Copy link
Member

taion commented Dec 28, 2015

Yeah, my bad; this is actually facebook/relay#502. Still nothing I can do about it though.

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

3 participants