Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relay.GraphQLMutation commit updates Relay.Store, Changes not reflected in UI #1546

Closed
mattferrin opened this issue Feb 15, 2017 · 1 comment

Comments

@mattferrin
Copy link

@josephsavona Requested this issue be created to discuss.

Having to override the network layer:

Relay.Store._storeData._mutationQueue._storeData._networkLayer = new DefaultNetworkLayer(customEndpoint, {
   credentials: 'same-origin'
})

Using these configs:

mutation.commit([{
  type: 'FIELDS_CHANGE',
  fieldIDs: {
    subViewer: 'singleton_sub_viewer_id',
  }
}])

Using this query:

let query = Relay.QL`mutation GraphM {
  insertEmployeeEvent(input: $input) {
    clientMutationId
    subViewer {
      timekeepingEmployeesEvents {
        employeeName
        eventTime
        eventType
      }
    }
  }
}`

The store updates fine, but doing a this.forceUpdate() on a parent component didn't re-render the changes to the records. I had to use forceFetch, but the Relay.Store after doing a forceFetch looks identical to me.

Relay.Store upon initial render:

{
   "_storeData":{
      "cachedRecords":{

      },
      "cachedRootCallMap":{

      },
      "queuedRecords":{

      },
      "records":{
         "client:-20020347631":{
            "__dataID__":"client:-20020347631",
            "__typename":"Viewer",
            "isAuthenticated":true,
            "isInRoleDesktopClient":true,
            "isInRoleInternal":true,
            "isInRoleOwner":true,
            "nEmployee":{
               "__dataID__":"client:-20020347632"
            },
            "subViewer":{
               "__dataID__":"singleton_sub_viewer_id"
            }
         },
         "client:-20020347632":{
            "__dataID__":"client:-20020347632",
            "__typename":"NEmployee",
            "employeeId":29641,
            "name":"Ferrin, Matt"
         },
         "singleton_sub_viewer_id":{
            "__dataID__":"singleton_sub_viewer_id",
            "__typename":"SubViewer",
            "timekeepingEmployeesEvents{employeeIds:[],fromDate:\"636227533873210000\",toDate:\"636227533873210000\"}":[

            ],
            "id":"singleton_sub_viewer_id",
            "timekeepingEmployeesEvents{employeeIds:[0:29641],fromDate:\"636227533873210000\",toDate:\"636227533873210000\"}":[

            ]
         }
      },
      "rootCallMap":{
         "viewer":{
            "":"client:-20020347631"
         }
      },
      "nodeRangeMap":{

      }
   }
}

Relay.Store in Relay.GraphQLMutation onSuccess callback after commit:

{
   "_storeData":{
      "cachedRecords":{

      },
      "cachedRootCallMap":{

      },
      "queuedRecords":{

      },
      "records":{
         "client:-20020347631":{
            "__dataID__":"client:-20020347631",
            "__typename":"Viewer",
            "isAuthenticated":true,
            "isInRoleDesktopClient":true,
            "isInRoleInternal":true,
            "isInRoleOwner":true,
            "nEmployee":{
               "__dataID__":"client:-20020347632"
            },
            "subViewer":{
               "__dataID__":"singleton_sub_viewer_id"
            }
         },
         "client:-20020347632":{
            "__dataID__":"client:-20020347632",
            "__typename":"NEmployee",
            "employeeId":29641,
            "name":"Ferrin, Matt"
         },
         "singleton_sub_viewer_id":{
            "__dataID__":"singleton_sub_viewer_id",
            "__typename":"SubViewer",
            "timekeepingEmployeesEvents{employeeIds:[],fromDate:\"636227533873210000\",toDate:\"636227533873210000\"}":[

            ],
            "id":"singleton_sub_viewer_id",
            "timekeepingEmployeesEvents{employeeIds:[0:29641],fromDate:\"636227533873210000\",toDate:\"636227533873210000\"}":[
               {
                  "__dataID__":"client:-20020347635"
               },
               {
                  "__dataID__":"client:-20020347636"
               }
            ],
            "timekeepingEmployeesEvents":[
               {
                  "__dataID__":"client:-20020347633"
               },
               {
                  "__dataID__":"client:-20020347634"
               }
            ]
         },
         "client:-20020347633":{
            "__dataID__":"client:-20020347633",
            "__typename":"EmployeeEvent",
            "employeeName":"Ferrin, Matt",
            "eventTime":null,
            "eventType":"FinishShift"
         },
         "client:-20020347634":{
            "__dataID__":"client:-20020347634",
            "__typename":"EmployeeEvent",
            "employeeName":"Ferrin, Matt",
            "eventTime":"2017-02-15T11:04:06.1Z",
            "eventType":"BeginShift"
         },
         "client:-20020347635":{
            "__dataID__":"client:-20020347635",
            "__typename":"EmployeeEvent",
            "employeeId":29641,
            "employeeName":"Ferrin, Matt",
            "employeeTimeAgreement":null,
            "employeeTimeClarification":null,
            "employeeTimeId":"19c610fd-790e-400b-a805-6870493f8ec4",
            "employeeTimeSignature":null,
            "eventName":"Finish Shift",
            "eventDate":"2017-02-15T11:04:06.1Z",
            "eventTime":null,
            "eventType":"FinishShift",
            "fundingSourceId":null,
            "fundingSourceName":null,
            "runId":null,
            "runName":null,
            "serviceId":null,
            "spaceType":null
         },
         "client:-20020347636":{
            "__dataID__":"client:-20020347636",
            "__typename":"EmployeeEvent",
            "employeeId":29641,
            "employeeName":"Ferrin, Matt",
            "employeeTimeAgreement":null,
            "employeeTimeClarification":null,
            "employeeTimeId":"19c610fd-790e-400b-a805-6870493f8ec4",
            "employeeTimeSignature":null,
            "eventName":"Begin Shift",
            "eventDate":"2017-02-15T11:04:06.1Z",
            "eventTime":"2017-02-15T11:04:06.1Z",
            "eventType":"BeginShift",
            "fundingSourceId":null,
            "fundingSourceName":null,
            "runId":0,
            "runName":null,
            "serviceId":null,
            "spaceType":null
         }
      },
      "rootCallMap":{
         "viewer":{
            "":"client:-20020347631"
         }
      },
      "nodeRangeMap":{

      }
   }
}

Relay.Store readyState after forceFetch:

{
   "aborted":false,
   "done":true,
   "error":null,
   "events":[
      {
         "type":"NETWORK_QUERY_START"
      },
      {
         "type":"CACHE_RESTORE_START"
      },
      {
         "type":"CACHE_RESTORED_REQUIRED"
      },
      {
         "type":"NETWORK_QUERY_RECEIVED_ALL"
      }
   ],
   "ready":true,
   "stale":false,
   "mounted":true
}

Relay.Store after forceFetch:

{
   "_storeData":{
      "cachedRecords":{

      },
      "cachedRootCallMap":{

      },
      "queuedRecords":{

      },
      "records":{
         "client:-20020347631":{
            "__dataID__":"client:-20020347631",
            "__typename":"Viewer",
            "isAuthenticated":true,
            "isInRoleDesktopClient":true,
            "isInRoleInternal":true,
            "isInRoleOwner":true,
            "nEmployee":{
               "__dataID__":"client:-20020347632"
            },
            "subViewer":{
               "__dataID__":"singleton_sub_viewer_id"
            }
         },
         "client:-20020347632":{
            "__dataID__":"client:-20020347632",
            "__typename":"NEmployee",
            "employeeId":29641,
            "name":"Ferrin, Matt"
         },
         "singleton_sub_viewer_id":{
            "__dataID__":"singleton_sub_viewer_id",
            "__typename":"SubViewer",
            "timekeepingEmployeesEvents{employeeIds:[],fromDate:\"636227533873210000\",toDate:\"636227533873210000\"}":[

            ],
            "id":"singleton_sub_viewer_id",
            "timekeepingEmployeesEvents{employeeIds:[0:29641],fromDate:\"636227533873210000\",toDate:\"636227533873210000\"}":[
               {
                  "__dataID__":"client:-20020347635"
               },
               {
                  "__dataID__":"client:-20020347636"
               }
            ],
            "timekeepingEmployeesEvents":[
               {
                  "__dataID__":"client:-20020347633"
               },
               {
                  "__dataID__":"client:-20020347634"
               }
            ]
         },
         "client:-20020347633":{
            "__dataID__":"client:-20020347633",
            "__typename":"EmployeeEvent",
            "employeeName":"Ferrin, Matt",
            "eventTime":null,
            "eventType":"FinishShift"
         },
         "client:-20020347634":{
            "__dataID__":"client:-20020347634",
            "__typename":"EmployeeEvent",
            "employeeName":"Ferrin, Matt",
            "eventTime":"2017-02-15T11:04:06.1Z",
            "eventType":"BeginShift"
         },
         "client:-20020347635":{
            "__dataID__":"client:-20020347635",
            "__typename":"EmployeeEvent",
            "employeeId":29641,
            "employeeName":"Ferrin, Matt",
            "employeeTimeAgreement":null,
            "employeeTimeClarification":null,
            "employeeTimeId":"19c610fd-790e-400b-a805-6870493f8ec4",
            "employeeTimeSignature":null,
            "eventName":"Finish Shift",
            "eventDate":"2017-02-15T11:04:06.1Z",
            "eventTime":null,
            "eventType":"FinishShift",
            "fundingSourceId":null,
            "fundingSourceName":null,
            "runId":null,
            "runName":null,
            "serviceId":null,
            "spaceType":null
         },
         "client:-20020347636":{
            "__dataID__":"client:-20020347636",
            "__typename":"EmployeeEvent",
            "employeeId":29641,
            "employeeName":"Ferrin, Matt",
            "employeeTimeAgreement":null,
            "employeeTimeClarification":null,
            "employeeTimeId":"19c610fd-790e-400b-a805-6870493f8ec4",
            "employeeTimeSignature":null,
            "eventName":"Begin Shift",
            "eventDate":"2017-02-15T11:04:06.1Z",
            "eventTime":"2017-02-15T11:04:06.1Z",
            "eventType":"BeginShift",
            "fundingSourceId":null,
            "fundingSourceName":null,
            "runId":0,
            "runName":null,
            "serviceId":null,
            "spaceType":null
         }
      },
      "rootCallMap":{
         "viewer":{
            "":"client:-20020347631"
         }
      },
      "nodeRangeMap":{

      }
   }
}
@wincent
Copy link
Contributor

wincent commented May 27, 2017

Closing out old issues referring to the old APIs because those are no longer being worked on. All future development is taking place against the new Relay Modern core and APIs that just came out, so please file any subsequent issues against that.

@wincent wincent closed this as completed May 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants