1

I'm trying to use decorators to simplify creating Relay containers like in this gist: https://gist.github.com/miracle2k/f39aaaccbc0d287b2ddb

Unfortunately, it's not working and erroring with Invariant Violation: RelayQueryNode: Abstract class cannot be instantiated.

There's nothing particularly interesting or strange about my code. Something similar to:

function relayDecorator(component) {
  return createContainer(component, { fragments: component.fragments })
}

@relayDecorator
class Component extends React.Component {
  static fragments = {
    viewer: () => Relay.QL`
      fragment on Viewer {
        email
      }
    }
  `
}

Does anyone have any idea why this is happening? I've tried to debug this for some time and can't get it working.

It works just fine if I create the container all by itself, outside of a decorator function.

EDIT: This has nothing to do with the decorators not working. I have decorators working just fine for other things, it is a Relay question.

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
dphaener
  • 140
  • 1
  • 8
  • also relevant http://phabricator.babeljs.io/T2645 – zerkms Jan 07 '16 at 03:17
  • Thanks for that, but it's not an issue with decorators. It's an issue with Relay. – dphaener Jan 07 '16 at 05:24
  • My apologies then, I misunderstood the problem. – zerkms Jan 07 '16 at 05:30
  • @dphaener Do you happen to have a small (but full) reproducible example to clone or experiment with? – Michelle Tilley Jan 07 '16 at 15:43
  • 1
    Thanks for the response Michelle. In attempting to create an example for you (the one I'm working on is private code unfortunately), I narrowed down the problem. I'm using isomorphic-relay for server rendering, and it looks like the issue is happening in that module. I'm going to move this discussion over to an issue there. Thanks again! – dphaener Jan 07 '16 at 16:25
  • For those tracking this, I had a hard time tracing it back to the isomorphic-relay module. This is a very tricky thing, and I'm checking back with the Relay folks.... – dphaener Jan 19 '16 at 21:29
  • @dphaener any updates? – Muers Aug 19 '16 at 15:19
  • @Muers unfortunately no. I gave up on this one... :( – dphaener Aug 20 '16 at 17:14

0 Answers0