relayjs

Purpose of @relay(pattern:true)

风格不统一 提交于 2019-12-18 04:46:07
问题 New expression @relay(pattern: true) was introduced in change log for relay.js 0.5 . But can't figure out from description nor tests what exactly it does and when I should use it when writing fatQueries . Some example would be very helpful. 回答1: Consider a GraphQL query like the following: viewer { friends(first: 10) { totalCount edges { node { name } } pageInfo { hasNextPage } } } When defining a fat query for a Relay mutation, to include the name of a field without specifying any of its

Relay Error when deleting: RelayMutationQuery: Invalid field name on fat query

房东的猫 提交于 2019-12-14 04:25:55
问题 I'm running into an issue when I attempt to commit a deletion mutation. When I commit, I get the error Uncaught Invariant Violation: RelayMutationQuery: Invalid field name on fat query, `company`. . Viewing, creating and updating nodes all work. For some reason I just can't delete. It mentions the company field in the fatQuery, but the only field I have in the fat query is the deletedUserId I get back from the server. Thanks in advance! Component: import React, {Component} from 'react';

How to tell the user to log in with relay?

邮差的信 提交于 2019-12-13 19:22:41
问题 Almost all of my graphql objects require that the user is authenticated to access them. If the user is not logged in, or their credentials are invalid, the server returns an error with a flag requireLogin set to true . How can I intercept errors wherever they occur in Relay, capture this specific error, and then use it to update my state in redux (which will then show a message and a login box)? The ideal place seems to be the NetworkLayer, but before I implement my own custom NetworkLayer is

How to fetch and display item by id using Relay container, react-router and GraphQL

时光总嘲笑我的痴心妄想 提交于 2019-12-13 12:23:00
问题 I am having a really hard time trying to get my head around Relay routes, react-router params and building the queries and containers in general! I want to edit a Feature when the user clicks on a specific Feature in a FeatureList. It passes a param called "id" which is the id of the Feature in Route.js <Route path='/' component={AppComponent} queries={ViewerQuery}> <IndexRoute component={FeaturesContainer} queries={ViewerQuery} /> <Route path='/feature' component={FeatureComponent} queries=

Determining when Relay is fetching query data

寵の児 提交于 2019-12-13 07:20:16
问题 I'm using Reactjs and Relayjs in my web application. One of the pages, I call it memberList , is displaying a list of all users registered on the website. This is a simplified version of my implementation: render() { {this.props.memberList.edges.length > 0 ? <ol> {this.props.memberList.edges.map( (member, i) => { return <li>{member.node.username}</li>; } )} </ol> : <span>No members to show!</span>} } And my RelayContainer: export default Relay.createContainer(MemberList, { fragments: {

Relay Cache with Flux Pattern?

送分小仙女□ 提交于 2019-12-12 09:40:00
问题 I'd really like to incorporate the Relay cache within my Flux store so I can do "time-travel" and gain deep insight into the application. It looks like the Relay store and actions are all classes which aren't serializable which is bummer. But it looks like I ought to be able to separate the cache from the network requests and save the cache in a Flux store. Does that sound interesting or am I barking up the wrong tree? 回答1: Relay can certainly be used alongside Flux, and we've spoken to many

async await inside function not working properly?

混江龙づ霸主 提交于 2019-12-12 04:44:07
问题 I have this function, that i need to define an async function inside it: _refetchConnection = (page) => { // query for cursor page const refetchVariables = async (fragmentVariables) => { let pageCursor; if(page !== 1) { const getAfterCursorQueryText = ` query($count: Int!, $cursor:String) {# filename+Query viewer { publicTodos (first: $count, after: $cursor) { edges { cursor node { id } } pageInfo { # for pagination hasPreviousPage startCursor hasNextPage endCursor } } } }`; let cursor =

React Relay: Complex mutation fat query

混江龙づ霸主 提交于 2019-12-12 02:39:09
问题 I'm creating a voting applications with polls that can be voted. I'm currently stuck on voting for a poll (essentially, creating a vote). My schema: (Long story short: polls are accessible from the main store, but the viewer's polls and votes can be accessed directly by him (as fields). votes also are accessible from the min store, but the poll's votes can be accessed also directly by it. query { store { polls { //poll connection edges { node { //poll votes { //vote connection ... } } } }

Relay client for existing working graphQL server?

六眼飞鱼酱① 提交于 2019-12-12 02:34:31
问题 I have working tinySQL GraphQL server running at 127.0.0.1:3000. I would like to create any working Relay client for it. I mean any working example for query: { groupBy (age: 20, job: "student") { id, name, age, job } } that will output in React component something like that: { "data": { "groupBy": [ { "id": 1, "name": "Marie", "age": 20, "job": "student" }, { "id": 5, "name": "Jessie", "age": 20, "job": "student" } ] } } Most important thing is I want to be able to set GraphQL host IP and

How do I set default props for a component wrapped in a Raley container?

不打扰是莪最后的温柔 提交于 2019-12-11 08:17:58
问题 I have a component wrapped in a Relay container: const Widget = (props) => { return ( <div> { props.foo.bar } </div> ) } Widget.defaultProps = { foo: {bar: 0} } export default Relay.createContainer(Widget, { fragments: { store: () => Relay.QL` fragment on WidgetData { foo { bar } } ` } }) I'm using a GraphQL-as-a-service provider for a backend, and when the foo property of WidgetData isn't present, it returns null , which throws when my component attempts to render props.null.bar As far as I