GraphQL not working with NodeJS created Realm?


#1

Hello,
I have created a realm in my cloud account via a node server (I provided a schema and inserted one object in one of the tables with the same nodejs server).
In realm studio I can open the realm, see the tables and the data, but with GraphQL I always have this error for every request, and also on the Graphiql explorer :
Syntax Error: Expected Name, found } in GraphQL Explorer

I’ve read here that this happens when no schema nor data has been created but in this case I did and I can see it in Realm Studio.

Also I created another Realm with Realm Studio and I can use it without any issue with graphql. It is only the one I’ve created with nodejs that can’t be used.
Are there limitations with realms created outside of Realm studio ?
Thanks


CORS issue with client-side graphql
#2

Do you have objects that have no properties? This could also be a reason to get this error.


#3

Thanks for the quick answer. All of my objects have a primary key and properties.

I managed to make it work by changing the name of the Realm I’m trying to create.
I think there is an issue when we delete a realm with Realm Studio and then we try to create a new one with the same name.
I’m currently in development phase so I occasionally need to delete the whole realm and create a fresh new one. I usually delete it using Realm Studio and then I trigger my nodejs server to recreate a new one after that. Creation works well and I can see/browse the fresh new one in Realm Studio, but it’s no working with graphql. If I create a new one with a different name then it seems to work.

Is there some kind of cache or delay before everything gets deleted for real in Realm Cloud ?


#4

Yes, there is some caching at the GraphQL layer, but it’s supposed to handle that gracefully and invalidate the cache when a Realm is deleted. I’ve opened a Github issue to track that: https://github.com/realm/realm-graphql-service/issues/80.


#5

ok cool, hope you’ll find what’s wrong here.
In the spirit of helping in the investigation I’ve discovered another issue related to cached info on deleted realm.
I’ve deleted my realm (with studio, and it was gone), changed one of the properties type in my schema and tried to recreate the realm with the same name using node js.
I got an exception telling me I couldn’t change the type of a property because change should be additive only.
I would have understood this error if I tried to update an existing realm, but here I was creating a new one. I changed the new realm name and it worked. Looks like it tried to update the deleted realm instead of creating a new one.
So the caching issue is there even outside of graphql.
Hope this helps
Thanks


#6

Yes - GraphQL uses our node.js SDK under the hood and I’ve managed to reproduce the problem and it’s deeper than anticipated :confused: We’ll work on a fix and we’ll update you when that’s released. In the meantime, the only workaround is to not recreate Realms.


#7

Hello,
I’ve seen the ticket is still open so I guess it’s not fixed yet.
What is the delay of the caching issue ?
Can I start reusing older names after a while ? It’s getting difficult to find new names for my databases every time I try to reset them
Thanks


#8

Hi, we integrated the GraphQL service into ROS some time ago and must have forgotten to close the issue. I believe it is fixed now. Can you check if you’re still experiencing the problem after deleting the Realm?


#9

Hi, good to know, I’ll try it soon and let you know. Thanks!


#10

@nirinchev no, still not working. I’ve deleted a realm called “scenario” from Realm Studio and created a new one with the same name using node sdk. The creation went well and the realm appeared in studio.
With graphql, all requests timeout on the new database with the same name. If I create a new database with a different name, the request are working.


#11

Agh, I forgot you were running on cloud :man_facepalming: We haven’t rolled out the fix to all instances yet - that should happen later this week. If you message me your instance name and a convenient time for an upgrade (usually takes your instance down for 2-3 minutes), I can upgrade it straight away.


#12

no problem, glad to see I wasn’t doing anything wrong. Not able to test it again because I went on production last week. Can’t delete my database anymore. I ended up with a name suffixed with the date to work around the issue. Thanks