Hello!
I am attempting to execute queries on a newly created collection via the GraphQL api using Apollo.
The frontend auths via an API key, the call to get an access token is successful.
When attempting to run any queries after this I can see the bearer token appended however every call returns a 404 and the error:
cannot find app using Client App ID $CLIENT_ID
The full error details are here:
{
"graphQLErrors": [],
"clientErrors": [],
"networkError": {
"name": "ServerError",
"response": {},
"statusCode": 404,
"result": {
"error": "cannot find app using Client App ID $MY_CLIENT_ID
}
},
"message": "Response not successful: Received status code 404"
}
I’ve verified that the client ID is correct. I’ve attempted to delete the entire cluster and re-create it in another region with no luck.
Is there some issue with locating newly created clusters or is there some configuration in the UI I am missing?
I am able to access the console at http://cloud.mongodb.com/ and I can successfully run queries in GraphiQL there.
I am aware there is an old thread about this though this issue seems to have resurfaced
fwiw auth code is as follows:
async function getValidAccessToken() {
if (!app.currentUser) {
console.log("getting api key creds");
await app.logIn(Realm.Credentials.apiKey(API_KEY));
console.log("got credentials!");
} else {
await app.currentUser.refreshCustomData();
console.log("refreshed");
}
return app.currentUser?.accessToken;
}
export const apolloClient = new ApolloClient({
link: new HttpLink({
uri: `https://realm.mongodb.com/api/client/v2.0/app/${APP_ID}/graphql`,
fetch: async (uri, options) => {
console.log("fetching");
const accessToken = await getValidAccessToken();
console.log(accessToken);
(
options?.headers as Record<string, string>
).Authorization = `Bearer ${accessToken}`;
return fetch(uri, options);
},
}),
cache: new InMemoryCache(),
});