ramsaylanier / WordExpressSchema

This package provides a connection to a WordPress database using Sequelize and provides a standard set of GraphQL queries.
148 stars 31 forks source link

Bug with "menus { navitem }" #6

Closed rvetere closed 7 years ago

rvetere commented 8 years ago

Hi there,

i'm implementing your awesome GraphQL backend stack into my own webpack/react.js app setup - which is already relay/ssr activated 😉

But relay especially is pretty picky when it comes about Types in GraphQL. So i stumbled upon this error in the "menus" query:

fig1

After checking it more deeper i found out, relay wants to have "id" fields always delivered as "string" - otherwise such errors starts to occur (and the entire app breaks!)

In the POST request to graphql it is pretty clear:

fig1

the "id" of navitem is currently delivered as a "number" - which is exactly the error for relay 😕

If i take away "naviitem" completely, it starts to work again... I started a fork now of "WordExpressSchema" - but i'm a bit lost to see how i could fix that.

ramsaylanier commented 8 years ago

I'll have to take a deeper look into this. I should not that I'm no longer using relay, but apollostack. All the documentation should have been updated - you can read more about Apollo here.

ramsaylanier commented 8 years ago

You could try changing this line from ID! to String!

https://github.com/ramsaylanier/WordExpressSchema/blob/master/src/definitions.js#L3

Its weird though that your menuID is a string but the navItemID is a number.

rvetere commented 8 years ago

Great! Thanks for your advice - now i'm able to hack around in any level of the app, that's awesome! 👍

It was not the field you mentioned -> but it was still in the schema -> i just had to change the "id" definition of "post" instead of "MenuItem" and i got just the relay error away.

Cool you're using the apollo stack - but i love relay and especially relay-react which is so extremely nicely patching the graphql's together with components (you remove the component in the jsx? i stop to pull this fragment for that). I'm not telling apollo couldn't do the same - it's just... i'm not going to learn "just another" new tech to get a hobby project done quickly, after i just learned everything new this year 😆

For me the issue is solved 👍