relaymodern

Implement multiple interfaces in graphql

冷暖自知 提交于 2020-01-03 19:16:20
问题 I am using the relay compiler and it is not letting me compile a schema with a type that implements multiple interfaces. I made a small test project: package.json { "scripts": { "relay": "relay-compiler --src ./ --schema schema.graphqls" }, "dependencies": { "react-relay": "1.5.0" }, "devDependencies": { "relay-compiler": "1.5.0" } } schema.graphqls interface First { a: String } interface Second { b: String } type Something implements First, Second { a: String b: String } test.js import {

Refetch method for createRefetchContainer doesn't execute callback

六眼飞鱼酱① 提交于 2019-12-24 18:51:29
问题 My QueryRenderer uses the following Query: ``` graphql` query page_Query { viewer { id ...MountedRenderer_viewer } } ` and this is what my createRefetchContainer looks like: ``` createRefetchContainer( MountComponent, graphql` fragment MountedRenderer_viewer on User @argumentDefinitions(show: { type: "Boolean", defaultValue: false }) { id name @include(if: $show) } `, graphql` query OwnershipsRenderer_Query($show: Boolean!) { viewer { ...MountedRenderer_viewer @arguments(show: $show) } } `, )

How to best access data from QueryRenderer in a parent component in Relay Modern?

只愿长相守 提交于 2019-12-24 12:24:26
问题 As you can see from the picture below, I'm rendering the popover using a react-relay QueryRenderer since the request is slow, and I do not want the rest of the page to wait for events to be fetched. My problem is that in the navigation I have a button to show/hide the popover. That button should only be rendered when events has loaded, and the button also needs to show a count of how many events there is. So my question is how to pass events data up from QueryRenderer (popover) to a parent

relay refetch doesn't show the result

不想你离开。 提交于 2019-12-22 10:40:37
问题 I'm trying to create a live search-result component(lazy load one). It works perfectly for the first time but refetch doesn't update the data. I see the request and respoonse in Network tab! so it does get the data, but it doesn't supply it to the component! any idea why? import React, { Component } from 'react'; import { createRefetchContainer, graphql, } from 'react-relay'; import ProfileShow from './ProfileShow'; class ProfileList extends Component { render() { console.log("rendering....",

Pass variables to fragment container in relay modern

℡╲_俬逩灬. 提交于 2019-12-18 13:21:15
问题 I'm using Relay Modern (compat). I have a fragment that contains a field that has one argument, but I can't find a way of passing the variable value from the parent component: // MyFragmentComponent.jsx class MyFragmentComponent extends Component {...} const fragments = { employee: graphql` fragment MyFragmentComponent_employee on Employee { hoursWorked(includeOvertime: $includeOvertime) dob fullName id } `, } export default Relay.createFragmentContainer(MyFragmentComponent, fragments) It

AddMutation using relay modern graphql

倾然丶 夕夏残阳落幕 提交于 2019-12-13 03:36:29
问题 I'm trying to add a user using relay , below is my schema file schema.graphql createUser(input: CreateUserInput!): UserPayload input CreateUserInput { clientMutationId: String data: CreateUserData! } type CreateUserData { firstName: String! lastName: String! password: String! email: String } type UserPayload { clientMutationId: String node: User } type User { id: ID! firstName: String! lastName: String! email: String password: String } below is my mutation file , AddUserMutation.js const

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 =

Relay Modern nested pagination

别来无恙 提交于 2019-12-09 07:14:22
问题 I have a root query of songs , this is in a pagination container. I then have a nested property on songs called comments that I also want to be paginated because I don't want to load 10k comments for each song all at once. songsContainer.js: fragment songsContainer on Query { songs( first: $count after: $cursor genre: $genre filter: $filter ) @connection(key: "songsContainer_songs") { edges { node { audioId name coverImageUrl artist likes dislikes ...commentsContainer } } } } const

Relay Modern nested pagination

99封情书 提交于 2019-12-03 09:10:31
I have a root query of songs , this is in a pagination container. I then have a nested property on songs called comments that I also want to be paginated because I don't want to load 10k comments for each song all at once. songsContainer.js: fragment songsContainer on Query { songs( first: $count after: $cursor genre: $genre filter: $filter ) @connection(key: "songsContainer_songs") { edges { node { audioId name coverImageUrl artist likes dislikes ...commentsContainer } } } } const connectionConfig = { direction: 'forward', query: graphql` query songsContainerForwardQuery( $count: Int! $cursor

Pass variables to fragment container in relay modern

淺唱寂寞╮ 提交于 2019-11-30 09:08:20
I'm using Relay Modern (compat). I have a fragment that contains a field that has one argument, but I can't find a way of passing the variable value from the parent component: // MyFragmentComponent.jsx class MyFragmentComponent extends Component {...} const fragments = { employee: graphql` fragment MyFragmentComponent_employee on Employee { hoursWorked(includeOvertime: $includeOvertime) dob fullName id } `, } export default Relay.createFragmentContainer(MyFragmentComponent, fragments) It will end up saying $includeOvertime is not defined. The context where this component is being rendered