Syntax Error: Expected Name, found } in GraphQL Explorer


#1

When querying https://[MY_INSTANCE].cloud.realm.io/graphql/explore/%2f[REALM_PATH] in GraphQl explorer I receive “Invalid options provided to ApolloServer: Syntax Error: Expected Name, found }” and the documentation explorer says “No Schema Available”. When navigating to this Realm in Realm Studio there is definitely both a schema and data.

Where am I going wrong?


GraphQL not working with NodeJS created Realm?
#2

This error usually indicates that the Realm file is empty (no schema and no data). Since you say that you can see the schema and data in Studio, can you double check that the paths are identical? If that’s the case, I’ll need a repro case or credentials to connect to your cloud instance to try and debug it.


#3

Fixed - forgot to encode URL in the path. Thanks!


#4

Sorry, @nirinchev, run into another problem.

The client I’m using to query the Realm GraphQL is encoding the “%2f” user to a “/user” (in bold below), which is causing a 404 error.

https://[MY_INSTANCE].cloud.realm.io/graphql/[REALM_PATH]%2fuser?query{QUERY}

Encoding/Decoding other parts of the URL don’t affect the result (tested this in a browser) - only this character. Is there a workaround for this?


#5

I’m not sure I understand the question - what is /user and why does it get appended to the url?


#6

Thanks for your reply.

When using GraphQL, if %2fuser isn’t appended on to the request (https://[MY_INSTANCE].cloud.realm.io/graphql/[REALM_PATH]?query{QUERY}) I get a “Invalid options provided to ApolloServer: Syntax Error: Expected Name, found }” error. This is resolved when appending “%2fuser” to the path

https://[MY_INSTANCE].cloud.realm.io/graphql/[REALM_PATH]%2fuser?query{QUERY}

The issue is, the client I’m using to query Realm is decoding the “%2f” to “/”

https://[MY_INSTANCE].cloud.realm.io/graphql/[REALM_PATH]/user?query{QUERY}

Which is returning “Cannot GET /graphql/[REALM_PATH]/user”

Is there an alternative path accessing a realm, other than encoding “%2fuser”?


#7

What client are you using? This seems like a bug in the client - it should not be trying to decode the service urls. Also, can you post the code that you use to setup the client?


#8

Thanks, It’s definitely a bug on the client side and been logged with them as such (using MS Power BI/Power Query).

I was wondering if there was a workaround on the realm side, given that only that character must be encoded?

I’ve tested queries in a browser but only that precise character seems to require encoding.


#9

The slash needs to be encoded, yes. I can try and see if we can lift that limitation with a catch-all route parameter.


#10

Brilliant - thank you very much!


#11

@seann I made a change to our GraphQL service to handle non-encoded paths. It seems you’re running this on cloud, so you’ll need to wait for the next upgrade window, which will be mid-next week or if you PM me your instance id though, I can upgrade your instance to the latest version manually.