Fix: caching now works again

This commit is contained in:
Douglas Barone 2020-12-19 10:39:53 -04:00
parent 5ff60ee8c5
commit 784b4fbaf8
3 changed files with 19 additions and 11 deletions

View File

@ -33,10 +33,13 @@ const server = new ApolloServer({
},
plugins: [
responseCachePlugin({
sessionId: requestContext =>
requestContext.request.http.headers.get('Authorization') ||
requestContext.request.http.headers.get('authorization') ||
null
sessionId: requestContext => {
return (
requestContext.request.http.headers.get('authorization') ||
requestContext.request.http.headers.get('Authorization') ||
null
)
}
})
]
})

View File

@ -5,8 +5,7 @@ const typeDefs = gql`
"Returns only a few fields of User"
basicUser(sAMAccountName: String!): User! @cacheControl(maxAge: 350)
me: User! @auth
"@cacheControl(maxAge: 30, scope: PRIVATE)"
me: User! @auth @cacheControl(maxAge: 30, scope: PRIVATE)
users(
where: UserWhereInput!
limit: Int = 15
@ -21,7 +20,7 @@ const typeDefs = gql`
@auth(roles: ["servant"])
@cacheControl(maxAge: 350)
stats: Stats!
stats: Stats! @cacheControl(maxAge: 30)
userPresence(search: String = ""): [UserPresence!] @auth(roles: ["watcher"])
@ -29,11 +28,17 @@ const typeDefs = gql`
search: String = ""
identifiedOnly: Boolean = false
nonIdentifiedOnly: Boolean = false
): [WifiDevice]! @auth(roles: ["superAdmin"])
): [WifiDevice]!
@cacheControl(maxAge: 10, scope: PRIVATE)
@auth(roles: ["superAdmin"])
wifiUsers: [User]! @auth(roles: ["superAdmin"])
wifiUsers: [User]!
@auth(roles: ["superAdmin"])
@cacheControl(maxAge: 10, scope: PRIVATE)
logs: [Log]! @auth(roles: ["superAdmin"])
logs: [Log]!
@auth(roles: ["superAdmin"])
@cacheControl(maxAge: 5, scope: PRIVATE)
}
type Mutation {

View File

@ -28,7 +28,7 @@ const defaultOptions = {
persisting: false,
// Use websockets for everything (no HTTP)
// You need to pass a `wsEndpoint` for this to work
websocketsOnly: true,
websocketsOnly: false, // true não funciona com a cache do servidor!
// Is being rendered on the server?
ssr: false