#Graphql not working

57 messages Β· Page 1 of 1 (latest)

halcyon timber
#

Hi!

All of a sudden graphql has stopped returning any data for all media relation fields of type upload. If the field is not required I'm getting just null, and when it's I'm getting error: cannot return null for non-nullable field.

The REST API is working as expected. The graphql just stopped working at some point. I'm using Payload version v2.0.0 if that helps.

At this point I'm pretty hopeless, so any help would be awesome.

opal thistle
#

do you get any errors in your console? And what kind of DB are you using?

halcyon timber
#

I'm using mongodb. I only get error when field is required, and I run the query. Then the error of status 500 is: cannot return null for non-nullable field

#

Otherwise I just get null for all upload fields.

opal thistle
#

exactly which version of Payload are you using. And for issues, can you please attach a project to help with debugging πŸ™‚

halcyon timber
#

I'm using 2.0.0

#

No I'm trying to create fresh project, and just move all my files

#

to the new one

opal thistle
#

what happens if you use a newer version of Payload? 2.0.0 is quite old

halcyon timber
#

I've tried 2.15.0 with no luck

#

So now giving a spin for completely fresh install

#

I could attach the project, but it's for client, so I would have to create reproduction repo πŸ™‚ But the thing is - I don't know how I ended up in this situation

halcyon timber
#

@opal thistle Ok, I've dropped the database completely, I made fresh Payload project, copied my files - still no luck.

#

I will now create fresh project with just media collection to see if it's gonna work.

#

Yea, no luck with fresh installation πŸ˜„ I will add it as a reproduction to the github issue

#

@opal thistle I've just added the reproduction repo and steps on how to reproduce it.

opal thistle
#

good stuff, thank you!

#

I see you are using plugin-cloud v3, does downgrading it to v2 help?

halcyon timber
#

Will check πŸ‘€

#

No luck :/

opal thistle
#

ok, looks like this is a real issue in that case. Thanks for the reproduction!

halcyon timber
#

My "pleasure" πŸ˜‰

#

Thank you for great work

#

So far I love experience with Payload

#

You really are closing the gap

opal thistle
#

oh i'm not in the Payload team, I'm just a contributor πŸ˜„

#

but they are great!

#

I'm curious if this is maybe something to do with transactions. Could you add transactionOptions: false to the mongooseAdapter implementation?

#

This can happen if you use MongoDB ATLAS

halcyon timber
#

Currently I'm using mongo installed locally, but try this as well

#

Nothing

#

I forgot to add read access to Pages collection in reproduction

#

but I've already corrected that

#

Pushed to main

#

Some additional context: I've installed a package via npm, so maybe, just maybe there was a new version of some graphql package released, that payload is using?

#

That could break a thing too

opal thistle
#

yeah this is a really strange bug

#

What happens if you add fields to your Media collection?

#

I'm clutching at straws a bit haha

halcyon timber
#

will try! πŸ˜„

#

Absolutely nothing happens

halcyon timber
#

btw, @opal thistle did you check the reproduction repo? Because I'm wondering if it's really broken

opal thistle
#

not yet, I'm AFK just now so just checking on my phone

halcyon timber
#

Oh, I see, no worries!

opal thistle
#

I’ll check this out tomorrow morning. I am really curious

untold jolt
#

I'm getting the same! Only getting the Cannot return null for non-nullable field in prod and not locally, even when sharing the same mongo db

halcyon timber
#

@untold jolt probably you are getting this error on required field, am I wrong? πŸ˜„

#

If you remove make field optional, you will get null according to my observations

untold jolt
#

Yes same as what you mentioned here:

If the field is not required I'm getting just null, and when it's I'm getting error: cannot return null for non-nullable field.

halcyon timber
#

As weird as it will sound: I'm glad I'm not the only one πŸ˜„

untold jolt
#

Super weird because:

  • Rest API is fine
  • I can query images locally via graphql (even running a prod build), just not when deployed (tried fly.io and railway)
  • I haven't changed anything recently
#

Here's what I get on a required image

#

And non required images just return null

untold jolt
#

I was trying to fix this for 4 hours and finally got it!!

#

I commented on your github thread, but basically there's an issue with the 2.14.0 release. I couldn't figure out why I wasn't getting the same locally, but after I reinstalled node_modules and then started getting it locally too, I realised my prod instance was on the newest minor version πŸ€¦β€β™‚οΈ