3

I am trying to implement pagination using relay in application. Displaying data in react-bootstrap table and pagination to navigate pages. First time when I hit page it loads first page data (executes root Query). On click event of on pagination (1, 2, 3 ..) I request server for next page data. as expected root query executes and fetches data But data on UI is not getting updated.. and in browser console I can see following error

Warning: Relay was unable to reconcile edges on a connection. This most likely occurred while trying to handle a server response that includes connection edges with nodes that lack an id field.

After pagination click I can see changes in url with required parameters say pageNum=2 and on page refresh it shows new data.. but data should come without page refresh.

Buddy566
  • 75
  • 1
  • 10

1 Answers1

2

In your server-side GraphQL schema definition where you define the connections for your GraphQL types, did you define field :id, !types.ID or globalIdField.

E.g. (in Javascript, but applicable to other languages)

var myObjectType = new GraphQLObjectType({
  name: 'MyObject',
  description: 'My Object',
  fields: () => ({
    id: globalIdField('MyObject'),
    ...
  })
})

var myObjectListType = new GraphQLObjectType({
  name: 'MyObjectList',
  description: 'List of My Objects',
  fields: () => ({
    id: globalIdField('MyObjectList'),
    denims: {
      type: myObjectConnection,
      ...
    }
  })
})

var {connectionType: myObjectConnection} =
  connectionDefinitions({name: 'MyObject', nodeType: myObjectType});

Possibly related to: Nested fragment data always the same in Relay

Community
  • 1
  • 1
nethsix
  • 800
  • 8
  • 17
  • Thanks for reply but I have field :id on my "myObjectType" and "myObjectListType". what else can be missing as for every page request I can see data coming in response but not updating react table on UI. – Buddy566 Apr 04 '16 at 06:04
  • In your myObjectType instance object that you resolve to/return as response, did the instance object have an `:id` field? GraphQL will use the combination of the type passed to `globalIdField` e.g., MyObject, and the instance object's `:id` field to generate a unique global ID. – nethsix Apr 04 '16 at 11:37
  • Yes instance object also have id field. e.g for myObjectType I resolve instance of myObject having id property and other required properties.. FYI, for each page, request goes to server and fetch data for that specific page. – Buddy566 Apr 05 '16 at 06:24
  • What about your `myObjectListType`? How did you create that object in the backend? Did it have an `:id` field? Did your create your `nodeDefinitions` interface such that it knows how to handle `myObjectListType`? Also how did you pass pageNum=2 to your GraphQL server? Posting more code would help. – nethsix Apr 05 '16 at 08:08
  • Thank you so much for hint.. Issue was with instance of myObjectListType.. id was missing there.. Again thanks for your help.. :) – Buddy566 Apr 05 '16 at 08:57
  • Glad that this helped! If this helped you solve the problem, could you kindly mark it as the answer? – nethsix Apr 06 '16 at 14:55
  • Thanks for trying. You cannot upvote yet but you can accept the answer (since you are the author) by clicking on the 'checkmark' just below the upvote/downvote arrows? http://meta.stackexchange.com/questions/23138/how-to-accept-the-answer-on-stack-overflow. – nethsix Apr 10 '16 at 01:25