Questions tagged [relayjs]

Relay is a JavaScript framework for building data-driven React applications

Declarative: Never again communicate with your data store using an imperative API. Simply declare your data requirements using GraphQL and let Relay figure out how and when to fetch your data.

Colocation: Queries live next to the views that rely on them, so you can easily reason about your app. Relay aggregates queries into efficient network requests to fetch only what you need.

Mutations: Relay lets you mutate data on the client and server using GraphQL mutations, and offers automatic data consistency, optimistic updates, and error handling.

Resources

Code: https://github.com/facebook/relay
Docs: https://facebook.github.io/relay/
Chat: https://reactiflux.slack.com/messages/relay/ (Get an invite here)

686 questions
7
votes
3 answers

Relay Modern fragment data is null

{this is Relay Modern } In my UserQuery.js, class UserQuery extends Component { render () { return ( { if(props){ …
Saud Punjwani
  • 343
  • 2
  • 12
7
votes
2 answers

How does the NodeInterface and nodeField work in relayjs and what does they mean

how does the nodeInterface refetch and do object identification, and what does the type represent and what does the obj represent, what is id here and what does instanceof mean const { nodeInterface, nodeField } = nodeDefinitions( (globalId) => { …
terik_poe
  • 497
  • 3
  • 16
7
votes
1 answer

Authorization in GraphQL servers

How to handle Authorization in GraphQL servers? Shall I pass the JWT token in the Authentication header of every requests and check for the authorized user after resolve() and check for the role of user on every query and mutation
p0k8h
  • 5,826
  • 4
  • 24
  • 36
7
votes
1 answer

Relay - set variable before query

I'm currently working on a page that displays the status of a certain set of "tasks" for a specific user. To fetch the data, I have the following Relay container: export default Relay.createContainer(TaskReview, { initialVariables: { limit:…
Chris
  • 48,555
  • 16
  • 95
  • 112
7
votes
2 answers

How to manage cursors and sorting in Relay?

We have a graphql server (not written in javascript) serving a paginated list of objects. We're trying to conform to the relay specification, but we've hit an interesting case that could use clarification. Specifically: are cursors allowed to depend…
Evan
  • 5,701
  • 20
  • 26
7
votes
1 answer

Cannot set property 'clientMutationId' of undefined

I am getting following error. when trying to run a mutation via graphiql. Please help me resolve this issue or point to a link where I can find react relay mutations example. mutation { createUser(input: {username: "Hamza Khan", clientMutationId:…
user1762608
  • 245
  • 1
  • 4
  • 8
7
votes
1 answer

How to get RelayJS to understand that a response from GraphQL is an array of items, not just a single item

I have a GraphQL server running with a schema roughly like this: type Card { id: String! name: String } type Query { card(name: String!): Card cards(power: String): [Card] } Notice that I have a query on a single card, but also on multiple…
Cameron Booth
  • 6,562
  • 5
  • 26
  • 21
7
votes
1 answer

How does Relay / GraphQL 'resolve' works?

I am trying out Relay and GraphQL. When I am doing the schema I am doing this: let articleQLO = new GraphQLObjectType({ name: 'Article', description: 'An article', fields: () => ({ _id: globalIdField('Article'), title: { type:…
Facundo Matteo
  • 1,687
  • 1
  • 12
  • 19
6
votes
2 answers

How granular should Relay/Apollo fragments be?

I'm using GraphQL + Relay in my app and find myself wrapping almost every component with createFragmentContainer, including those very low in the DOM hierarchy (usually functional components). Is that the right way to use fragments? I'm wondering…
Yangshun Tay
  • 33,183
  • 26
  • 102
  • 123
6
votes
2 answers

How to force a fetch in Relay modern

My top-level component includes a settings dialog that includes the user's credentials. When a change is made in that dialog and the dialog is dismissed (state is changed to dialogOpen=false), I want to force a new fetch from the server since the…
bjlevine
  • 782
  • 1
  • 5
  • 16
6
votes
0 answers

React Relay project directory structure organization

I'm starting to build projects using Relay and I[m a little confused about my project structure (I do use isomorphic approach). Here is my normal React project structure: -- project |-----src | |---components (React components with…
Mendes
  • 13,757
  • 24
  • 122
  • 217
6
votes
1 answer

Image Upload in GraphQL

how can i handle image uploads in graphql Through multer using express route to handle upload and query from graphql to view the images and other data app.use('/graphql', upload); app.use('/graphql', getData, graphqlHTTP(tokenData => ({ schema, …
terik_poe
  • 497
  • 3
  • 16
6
votes
1 answer

GraphQL & Relay Filtering UI

THE PROMPT If you were to build Google Calendar using relay, how would you structure the GraphQL schema and the Relay containers/components to properly handle showing & hiding multiple calendars? THE ATTEMPT One might imagine a schema like…
Matt Martin
  • 503
  • 2
  • 5
  • 16
6
votes
1 answer

Global, client-side application state in Relay

What is the current recommendation or best practice for dealing with global application state in a Relay app? I have some state is strictly client-side (e.g. is the navigation panel open or closed) that I need to manage, as well as some RESTful data…
grahamb
  • 799
  • 2
  • 7
  • 21
6
votes
2 answers

File Upload with Relay and graphql-dotnet

I'm trying to build a mutation within relay that includes a file. As soon as I implement the getFiles() method referenced here: https://facebook.github.io/relay/docs/api-reference-relay-mutation.html#getfiles Relay sends a multipart request causing…
Jon Lebensold
  • 241
  • 1
  • 10