React and Relay error scrapbook

Mar 3, 2016

I’m stumbling upon a few Relay errors for which the depths of the internet have no answer yet. So, mostly because I’ll just repeat them in six months, here’s what I did wrong. Your mileage may vary.

“Warning: RelayContainer: Expected prop products supplied to ChartComponent to be data fetched by Relay. This is likely an error unless you are purposely passing in mock data that conforms to the shape of this component’s fragment.”

The only answers I could find were related to modification queriesI must be uniquely stupid to trigger it with a simple query. Solution: thou shalldThat’s Shakespeare for really should have long ago read Thinking in react: Data Masking. When you include a child’s fragment, you want to pass it exactly the object(s) it’s asking for. To debug, set a breakpoint in the parent’s render()

Object {__dataID__: "Vmlld2VyLXs6aWQ9PiJyb290In0=", products: Object}
  __dataID__ "Vmlld2VyLXs6aWQ9PiJyb290In0="
  products: Object // <-- This is not the object you're looking for
      edges: Array[7]
          __dataID__: "client:client:17486589601:2"
          node: Object // <-- This is it. Always pass the object tagged "RelayFragmentPointer" as the child's prop
            2: RelayFragmentPointer

Find RelayFragmentPointer and pass that to the child.

“Warning: expected a single record…”

The warning is actually spot onUnlike me, apparently. This is starting to be a bit embarrassing</figure>: If you define your fragment as such:

fragment on Product {

…it expects to get a single Product as a prop. I did this in an attempt to delegate the edges { node { ... boilerplate to the parent component. That may actually not be advisable, as the query variables would then have to be defined in the parent as well, and they just don’t belong there. This works:

  fragments: {
    products: () => Relay.QL`
      fragment on Viewer {
        products(first: 100) {
          edges {
            node {

“No connection implementation to wrap Product…”

This one’s actually from the GraphQL Relay Ruby Gem. I had just implemented a 1:n (belongs_to / has_many) relationship in rails and mindlessly assumed I’d need the connection mechanism to recreate that relationship in GraphQL. But that’s obviously bollocks As of now, this error is one of those rare cases where google returns exactly one match – the source file on Github. I appear to be the ONLY PERSON EVER to have managed to trigger this. Then again I soothe myself with the assumption that only a few million ever tried.</figure> – from the belongs_to class of the relationship, the connected class is just a field:

field :product, -> {ProductType}


Other Articles

Mark Felt-Tipped Feb 25, 2018

Building Tensorflow 1.5.0 on MacOS with CUDA GPU Jan 21, 2018

Contact Jan 1, 2018

iTunes crashes with MediaControlSender AVSystemController_GetAirPlayInfo Aug 18, 2017

Add iterm2 marks to long-running outputs Jun 1, 2017

Trump Documents Atbash Decoded May 23, 2017

Polkit? WTF is this again? Actually... May 23, 2017

osacompile: no such component "JavaScript" May 2, 2017

" glxQueryVersion failed" with a headless chrome on alpine Mar 17, 2017

lighthouse/chromium/alpine/docker image Mar 9, 2017

Don't know how to build task '# Mar 6, 2017

sfdp: Error: Graphviz not built with triangulation library Jan 7, 2017

link_directory must be a directory Jan 2, 2017

Deactivating the Z170N's internal bluetooth in Clover Jul 3, 2016

Autogenerate a Dash Docset with Object Graph and documentation Statistics on Rails Migrate Jun 13, 2016

Massdrop is the worst spammer I've seen since the 90ies May 23, 2016

Verifying NGINX configurations in ansible May 23, 2016

ANSIBLE-MODULE-PATH and more Apr 29, 2016

'' is not a git command Apr 23, 2016

I rule (.svg) Mar 8, 2016

React and Relay error scrapbook Mar 3, 2016

Get a Grid, at least vertically Feb 17, 2016

Uncaught TypeError: Iterator value meps is not an entry object Nov 14, 2015

Controlled Jekyll Republishing with git Commit Messages Nov 2, 2015