Questions tagged [relay]

Relay is a JavaScript framework for providing a data layer and client-server communication to web applications using the React view layer.

Relay is a JavaScript framework for providing a data layer and client-server communication to web applications using the React view layer.

656 questions
4
votes
1 answer

How to obtain the `initialQueryRef` in Relay?

In the Relay docs, to fetch a query you have to first preload it using useQueryLoader, and then later pass the result of this into usePreloadedQuery. However, this first step, useQueryLoader takes two arguments: a query itself, which is easy to…
Migwell
  • 18,631
  • 21
  • 91
  • 160
4
votes
2 answers

Testing components using React Relay

I am using the new Relay Hooks and finding it difficult to get the tests passing. I am experiencing the issue mentioned in their docs. If you add the console.log before and after usePreloadedQuery, only the "before" call is hit //sample…
Charklewis
  • 4,427
  • 4
  • 31
  • 69
4
votes
2 answers

What is the difference between 'store-and-network' vs 'network-only'?

I've read the documentation, and I'm still confused about the difference between the fetch policy 'store-and-network' and 'network-only'. "store-and-network": will reuse locally cached data and will always send a network request, regardless of…
Adam Wall
  • 163
  • 8
4
votes
1 answer

How to update the store after a mutation with relay?

I'm struggling to figure out how this should work. I have an application that has a current user, so, the topmost query looks like this: query AppQuery { currentUser { id email ...Account_currentUser …
Marta Silva
  • 733
  • 1
  • 6
  • 13
4
votes
1 answer

How to understand null edges and nodes in GraphQL

The good practice for relations in GraphQL is using the connection model with edge and node elements. The recommendation is also for both edge and node to be nullable. This is how e.g. graphene-sqlalchemy, that I use will map the SQL relations. My…
zefciu
  • 1,967
  • 2
  • 17
  • 39
4
votes
0 answers

What is the best way to implement nested cursor pagination with a SQL datasarouce in a graphQL server?

How do you manage effective data fetching with nested cursors in a relay-esk schema (with a SQL data source)? Do you try make a single complicated SQL query to resolve the N+1 problem with a "LIMIT args_first", "ORDER BY args_orderby" and "WHERE…
Daniel Blignaut
  • 121
  • 1
  • 4
4
votes
2 answers

Load data from relay store while the query is loading

I have a common Header and Footer that displays data that it may be already in the relay store and the main PageComponent that expects data from the “query”, but I don’t want to display a full loading screen to the user, I want to display the…
Chris
  • 333
  • 1
  • 7
4
votes
3 answers

How to use (opaque) cursors in GraphQL / Relay when using filter arguments and order by

Imagine the following GraphQL request: { books( first:10, filter: [{field: TITLE, contains: "Potter"}], orderBy: [{sort: PRICE, direction: DESC}, {sort: TITLE}] ) } The result will return a connection with the Relay cursor…
Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110
4
votes
1 answer

Error when trying to unmask relay modern fragment that has arguments

I've got the following query: query ChatRefetchContainerRefetchQuery( $arg: ID! $arg2: Boolean! ) { ...PeopleFragment @arguments(arg: $arg, arg2: $arg2) } What I want todo is unmask the ContainerFragment data OUTSIDE of the fragment.…
James111
  • 15,378
  • 15
  • 78
  • 121
4
votes
1 answer

Implement multiple interfaces in graphql

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" }, …
Piotr
  • 4,813
  • 7
  • 35
  • 46
4
votes
0 answers

Relay modern: refetch doesn't update props

I'm trying to use createRefetchContainer of the Relay Modern. but the props aren't passed down to my component from the result of the refetch query. The refetch query runs okay and the response will come back from the server, but the ui doesn't get…
Mani Shooshtari
  • 760
  • 1
  • 6
  • 19
4
votes
1 answer

How to handle mutation errors on Relay Modern?

I´m using ReactJS with Relay for my client. Consider the following mutation: import { commitMutation, graphql } from 'react-relay'; import environment from '../../../../environment'; const mutation = graphql` mutation…
Mendes
  • 17,489
  • 35
  • 150
  • 263
4
votes
1 answer

Relay container with no data

I'm building an app as my first real foray into React, Relay and GraphQL, using Relay Modern. The basic case is, I have a login form component that doesn't really need any data; that is to say, the component renders a form, and has a corresponding…
metahamza
  • 1,405
  • 10
  • 26
4
votes
1 answer

Graphql: Must provide query string

I have a simple express graphql server: const schema = require('./schema'); const express = require('express'); const graphqlHTTP = require('express-graphql'); const cors = require('cors') const bodyParser = require('body-parser'); const app =…
Avraam Mavridis
  • 8,698
  • 19
  • 79
  • 133
4
votes
0 answers

Graphql query statements `graphql` not being interpreted by babel-plugin-relay

I´m trying to setup GraphQL on my Realy Modern application, but babel is not working with my grapqh queries.I´m getting the following runtime error: graphql: Unexpected invocation at runtime. Either the Babel transform was not set up, or it failed…
Mendes
  • 17,489
  • 35
  • 150
  • 263