abhiaiyer91/apollo-fragment

Cannot read property `replace` of undefined

masiamj opened this issue · 3 comments

Hi all,

This package looks great, and exactly like what I'm looking for; however, I'm having a really tough time getting the implementation right.

Here's a couple key pieces of my implementation:

Apollo Cache
screen shot 2018-08-09 at 4 36 58 pm

ApolloFragment Usage
screen shot 2018-08-09 at 4 37 58 pm

Fragment
screen shot 2018-08-09 at 4 38 51 pm

Error
screen shot 2018-08-09 at 4 39 00 pm

Do you see anything obvious about why I'd be receiving this error? My bet is it's something trivial, just having a tough time debugging for now.

Thanks for your help!

same here..

Hi there!

Internally, ApolloFragment wraps the fragment string passed in with gql. So in order for the above to work, drop the gql and just pass it in as a string.

We could do a check in the library to see if fragment is already a DocumentNode and omit wrapping gql internally!

Would love to see that PR!

Also the typename prop is extracted from the fragment passed in.