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

Function checkGraphqlHealth

packages/plugins/graphql/src/sdk/plugin.ts:649–738  ·  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

647};
648
649const checkGraphqlHealth = (input: {
650 readonly integration: IntegrationRecord;
651 readonly credential: {
652 readonly template: AuthTemplateSlug;
653 readonly values: Record<string, string | null>;
654 };
655 readonly spec?: { readonly operation: string };
656 readonly httpClientLayer: Layer.Layer<HttpClient.HttpClient>;
657}): Effect.Effect<HealthCheckResult, never> =>
658 Effect.gen(function* () {
659 const checkedAt = Date.now();
660 const decoded = yield* decodeGraphqlIntegrationConfig(input.integration.config).pipe(
661 Effect.option,
662 );
663 if (Option.isNone(decoded)) {
664 return {
665 status: "unknown",
666 checkedAt,
667 detail: "The GraphQL integration configuration is invalid. Edit it, then try again.",
668 } satisfies HealthCheckResult;
669 }
670
671 const config = decoded.value;
672 const operation =
673 input.spec?.operation ??
674 (config.introspectionHash === undefined ? GRAPHQL_HEALTH_OPERATION : undefined);
675 if (operation === undefined) {
676 return {
677 status: "unknown",
678 checkedAt,
679 detail: "No live schema health check is configured.",
680 } satisfies HealthCheckResult;
681 }
682 if (operation !== GRAPHQL_HEALTH_OPERATION) {
683 return {
684 status: "unknown",
685 checkedAt,
686 detail: `GraphQL health check operation "${operation}" is not supported. Use ${GRAPHQL_HEALTH_OPERATION}.`,
687 } satisfies HealthCheckResult;
688 }
689
690 const method = config.authenticationTemplate.find(
691 (candidate: GraphqlAuthMethod) => candidate.slug === String(input.credential.template),
692 );
693 const missing = missingCredentialVariables(method, input.credential.values);
694 if (missing.length > 0) {
695 return {
696 status: "expired",
697 checkedAt,
698 detail: `Enter a credential value for ${missing.join(", ")}, then try again.`,
699 } satisfies HealthCheckResult;
700 }
701
702 const auth = introspectHeadersForConnection(
703 config,
704 input.credential.values,
705 input.credential.template,
706 );

Callers 1

plugin.tsFile · 0.85

Calls 4

scrubCredentialValuesFunction · 0.85

Tested by

no test coverage detected