-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not support healthcheck endpoints such as /graphql/health
#958
Comments
Note: Redwood would very much like a custom healthcheck function so we can test deploy CI and make sure a query can fetch data from the associated database. We'd add some query string to Kingdom cannot issue POSTs apparently to test -- and for some reason Netlify may be encoding or double encoding
As the response is
|
Previously (and on "most" hosting providers) I was able to do something like this: Which made for an easy health check:
|
Ok, then there must be something going on elsewhere. I can confirm for some hosting providers GET is working: But not for others: |
I think I changed my mind and now I agree with you on using |
It does - one question: will Yoga support custom health check functions in the future? |
I'm working on that @dthyresson |
Ideally, it would work the same as documented here https://redwoodjs.com/docs/graphql#health-checks This is how RedwoodJS declared one with Helix -- and keeping the same method means we wouldn't have to change docs or tell people for to do differently.
And then that function was used before like:
Where the import type { APIGatewayProxyEvent } from 'aws-lambda'
import { Request } from 'graphql-helix'
import { CorsContext } from './cors'
const HEALTH_CHECK_PATH = '/health'
export type OnHealthcheckFn = (event: APIGatewayProxyEvent) => Promise<any>
export function createHealthcheckContext(
onHealthcheckFn?: OnHealthcheckFn,
corsContext?: CorsContext
) {
return {
isHealthcheckRequest(requestPath: string) {
return requestPath.endsWith(HEALTH_CHECK_PATH)
},
async handleHealthCheck(request: Request, event: APIGatewayProxyEvent) {
const corsHeaders = corsContext
? corsContext.getRequestHeaders(request)
: {}
if (onHealthcheckFn) {
try {
await onHealthcheckFn(event)
} catch (_) {
return {
body: JSON.stringify({ status: 'fail' }),
statusCode: 503,
headers: {
'Content-Type': 'application/json',
...corsHeaders,
},
}
}
}
return {
body: JSON.stringify({ status: 'pass' }),
statusCode: 200,
headers: {
'Content-Type': 'application/json',
...corsHeaders,
},
}
},
}
} |
We are also using healthchecks but we are using them on separate endpoints that are not Yoga related. To add to the context we use express app and only mount yoga on relevant endpoints. I have seen the readiness checks in the source code and have thought to myself that it looks a bit odd to me, but it's not my use case, but it's hard coded strings and not very configurable. But since it is part of Yoga's ambition to cater for healthchecks, then I would agree they should be more customizable. Perhaps
|
In RedwoodJS, when using helix, we had a healthcheck at the endpoint
/graphql/health
becausegraphql
was the serverless function for the graphQL server.Bit, with Yoga, please consider this code in
graphql-yoga/packages/common/src/server.ts
Line 312 in 55c01aa
Note that with helix, we checked
endsWith
vs Yoga checks===
the path.readiness
different fromhealth
and when should each be used?The text was updated successfully, but these errors were encountered: