Use Realm GraphQL Client with a global/shared realm in Realm Cloud

247 views Asked by At

I can successfully use the Realm GraphQL Client with a realm path like myInstance.us1.cloud.realm.io/~/realmName but when trying to use a global path, i.e., myinstance.us1.cloud.realm.io/realmName, I always get a 502 response from the server.

Any thoughts?

TLDR;

I have been fighting with getting data from a global/shared realm, i.e., no /~/ in the realm path with no luck. I always get a 502 Bad Gateway in response to executing a query. If I add the /~/ to the realm path, a connection is established and a new and empty user-specific realm is created (as expected) but then queries fail because the realm is empty (also expected).

Does the GraphQL Service provided by Realm Cloud support connecting to global/shared realms? I’ve skimmed over the source for both the server and client and did not see any specific reason why global/shared would not be supported.

I also tried passing isQueryBasedSync to the GraphQLConfig which results in a connection and successfully executed query, but the query responses are always empty

Any advice is greatly appreciated.

1

There are 1 answers

0
sellmeadog On

I got past the 502 Bad Gateway error using the undocumented API(s) shown below (I had to find them by reading the current code in the realm-graphql repo):

const credentials = Credentials.usernamePassword(<username>, <password>);
const user = await User.authenticate(credentials, <server>);
const config = await GraphQLConfig.create(user, <realm_name>, undefined, false);
const client = config.createApolloClient();

However, I now frequently receive the following error during GraphQLConfig.create execution:

network timeout at: https://.cloud.realm.io/auth

Additionally, I posted this question on the Realm Forums that you may want to follow and received the following response:

Getting a 502 in the GraphQL service usually means you were trying to open a very large Realm that runs into some resourcing limits.

I am still waiting for more information from the Realm team and will update this answer accordingly.