MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / checkGraphqlHealth

Function checkGraphqlHealth

packages/plugins/graphql/src/sdk/plugin.ts:680–770  ·  view source on GitHub ↗
(input: {
  readonly integration: IntegrationRecord;
  readonly credential: {
    readonly template: AuthTemplateSlug;
    readonly values: Record<string, string | null>;
  };
  readonly spec?: { readonly operation: string };
  readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;
})

Source from the content-addressed store, hash-verified

678};
679
680const checkGraphqlHealth = (input: {
681 readonly integration: IntegrationRecord;
682 readonly credential: {
683 readonly template: AuthTemplateSlug;
684 readonly values: Record<string, string | null>;
685 };
686 readonly spec?: { readonly operation: string };
687 readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;
688}): Effect.Effect<HealthCheckResult, never> =>
689 Effect.gen(function* () {
690 const checkedAt = Date.now();
691 const decoded = yield* decodeGraphqlIntegrationConfig(input.integration.config).pipe(
692 Effect.option,
693 );
694 if (Option.isNone(decoded)) {
695 return {
696 status: "unknown",
697 checkedAt,
698 detail: "The GraphQL integration configuration is invalid. Edit it, then try again.",
699 } satisfies HealthCheckResult;
700 }
701
702 const config = decoded.value;
703 const operation =
704 input.spec?.operation ??
705 (config.introspectionHash === undefined ? GRAPHQL_HEALTH_OPERATION : undefined);
706 if (operation === undefined) {
707 return {
708 status: "unknown",
709 checkedAt,
710 detail: "No live schema health check is configured.",
711 } satisfies HealthCheckResult;
712 }
713 if (operation !== GRAPHQL_HEALTH_OPERATION) {
714 return {
715 status: "unknown",
716 checkedAt,
717 detail: `GraphQL health check operation "${operation}" is not supported. Use ${GRAPHQL_HEALTH_OPERATION}.`,
718 } satisfies HealthCheckResult;
719 }
720
721 const method = config.authenticationTemplate.find(
722 (candidate: GraphqlAuthMethod) => candidate.slug === String(input.credential.template),
723 );
724 const missing = missingCredentialVariables(method, input.credential.values);
725 if (missing.length > 0) {
726 return {
727 status: "expired",
728 checkedAt,
729 detail: `Enter a credential value for ${missing.join(", ")}, then try again.`,
730 reason: "credential_missing",
731 } satisfies HealthCheckResult;
732 }
733
734 const auth = introspectHeadersForConnection(
735 config,
736 input.credential.values,
737 input.credential.template,

Callers 1

plugin.tsFile · 0.85

Calls 4

scrubCredentialValuesFunction · 0.85

Tested by

no test coverage detected