Provide an example of using sessionAuth when setting up an Engine
I cannot setup sessionAuth for private in-memory cache. Here's how the engine is set up
export default ({ apiKey, WebApp }) => {
const engine = new ApolloEngine({
apiKey,
logging: {
level: 'ERROR',
},
stores: [
{
name: 'inMemoryCache',
inMemory: {
cacheSize: 104857600, // 100 MB; defaults to 50MB.
},
},
],
sessionAuth: {
header: 'Authorization',
tokenAuthUrl: 'http://******.ngrok.io/engine-auth-check',
},
queryCache: {
privateFullQueryStore: 'inMemoryCache',
},
});
engine.meteorListen(WebApp);
};
The endpoint /engine-auth-check is defined the following way:
import express from 'express';
import { WebApp } from 'meteor/webapp';
export default () => {
const app = express();
app.post('/engine-auth-check', (req, res) => {
console.log('post request sent');
res.sendStatus(200);
});
WebApp.connectHandlers.use(app);
};
After I run queries a weird behaviour is observed. In traces queries have their scope as "Private" set up as well as TTL, but no cache hits is recorded. Additionally, tokenAuthUrl can be set to any string and no error will be returned.
I've checked the /engine-auth-check endpoint with Postman and it worked fine, but when I run queries, post request seems to not be sent.
@almostprogrammer The response from POST to /engine-auth-check should not return something like this ?
{ "ttl": 600, "id": "bob" }
Where bob is your unique value that you obtain after decrypt token from AUTHORIZATION header
I saw this in https://www.apollographql.com/docs/engine/proxy/guides.html#cache-hints