relayjs

Recursive data & components, later fetches throwing an error

青春壹個敷衍的年華 提交于 2019-12-07 10:31:35
问题 First off my graphql data model: type Human { id: !String, name: !String, children: [Human] } The only route (relay route config) I'm atm using: class extends Relay.Route { static queries = { human: () => Relay.QL`query RootQuery { viewer }` }; static routeName = 'AppHomeRoute'; } The list component: class HumanList extends Component { render() { let {children} = this.props.human; let subListsHTML = human ? children.map(child => ( <HumanListItem key={child.id} human={child}/> )) : ''; return

How to pass total count to the client in pageInfo

无人久伴 提交于 2019-12-06 23:00:42
问题 I use first after and last before to do pagination. hasNextPage and hasPreviousPage are very useful. But what I need is also the total count so that I can calculate and show things like page 5 of 343 pages on the client. Unfortunately that is not part of pageInfo even though I have the information on the server site. Can you please include a total field in the pageInfo and extend connectionFromArray to take in the total arrayLength like connectionFromArraySlice already does? Thanks 回答1:

Relayjs Graphql user authentication

江枫思渺然 提交于 2019-12-06 22:54:19
问题 Is it possible to authenticate users with different roles solely trough a graphql server in combination with relay & react? I looked around, and couldn't find much info about this topic. In my current setup, the login features with different roles, are still going trough a traditional REST API... ('secured' with json web tokens). 回答1: I did it in one of my app, basically you just need a User Interface, this one return null on the first root query if nobody is logged in, and you can then

Send a Cookie header field in relay request

心不动则不痛 提交于 2019-12-06 09:51:14
问题 It looks like stock relay networklayer does'nt send a cookie header field with his request. So I tried to add it by adding Cookie field like this: Relay.injectNetworkLayer( new Relay.DefaultNetworkLayer('/graphql', { headers: { 'Cookie': 'user=thibaut', }, }) ); but still the Cookie field is not present in my post request. If I replace 'Cookie' with 'Set-Cookie', IT IS in my post request... I need my server to use cookies please help ! :) 回答1: Set your cookies in the usual way (using browser

Fetch additional data for a single item in a list query

£可爱£侵袭症+ 提交于 2019-12-06 05:46:59
Im trying to do something like this with React and Relay - smooth animation from list to single item. I currently have list component (list query) and single item component (node query) but there's a problem: these are two different, isolated views and queries, I can't think of an easy way to smootly animate between these two views. Easiest way would probably be to transform / scale that same list item: React part is simple, I'll calculate screen size on click and transform the list item to full-screen size. How about data? Is something like this possible with Relay? Can I fetch more data for

Union types support in Relay

烈酒焚心 提交于 2019-12-06 04:44:52
问题 When you have defined field as an union of two types (in example machines contains Ships and Droid) then in Relay you can do something like that: fragment on Faction@ relay(plural: true) { name, machines { ... on Ship { name } ... on Droid { name, primaryFunction } } } so under machines prop your objects are correctly evaluated, but if you want to do that using fragments from external components: fragment on Faction@ relay(plural: true) { name, machines { ${StarWarsShip.getFragment('ship')} $

Should the opaque cursors in connections be stable across different field args?

China☆狼群 提交于 2019-12-05 20:32:12
The RANGE_ADD mutation requires an edgeName so that it can insert the new edge into the client side connection. As part of its query, it also includes the cursor . The issue is that the server has no way of knowing which args the client might be applying to a connection when it's generating the edge response. Does this mean that the cursor should be stable? In general, cursors are not required to be the same when connections are used with different arguments. For example, if I did: { namedFriends: friends(orderby:NAME first:5) { edges { cursor, node { id } } } favoriteFriends: friends(orderby

How to build a web app with GraphQL + parse.com? [closed]

雨燕双飞 提交于 2019-12-05 19:31:39
Closed . This question needs to be more focused . It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post . Closed 4 years ago . I would like to use parse and graphQL for a new app. It will essentially work with non logged in users, where people share a link and collaborate on some add hoc item. This will plan a meeting at a certain location. IS anyone aware of a solution or know of a way to approach this? It seems like it would be an awesome way to make apps. EDIT PARSE IS DEAD Yeah, you could certainly

Augment react-router module with react-router-relay typings

末鹿安然 提交于 2019-12-05 14:25:16
问题 The default react-router is used as such: import * as React from 'react'; import { Router, Route, hashHistory } from 'react-router'; const routing = ( <Router history={hashHistory}> <Route path="/login" component={Login}/> </Router> }; When I include the "react-router-relay" library, it adds functionality to the Router. Namely it adds 2 properties to the Router component (render and environment): import * as React from 'react'; import * as Relay from 'react-relay'; import * as useRelay from

Recursive data & components, later fetches throwing an error

蹲街弑〆低调 提交于 2019-12-05 13:54:04
First off my graphql data model: type Human { id: !String, name: !String, children: [Human] } The only route (relay route config) I'm atm using: class extends Relay.Route { static queries = { human: () => Relay.QL`query RootQuery { viewer }` }; static routeName = 'AppHomeRoute'; } The list component: class HumanList extends Component { render() { let {children} = this.props.human; let subListsHTML = human ? children.map(child => ( <HumanListItem key={child.id} human={child}/> )) : ''; return <ul>{subListsHTML}</ul>; } } export default Relay.createContainer(HumanList, { fragments: { human: () =