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.