Skip to content

feat(sdk): support typed documents in http adapters#1566

Merged
toiroakr merged 2 commits into
mainfrom
feat/http-adapter-typed-document-node
Jun 29, 2026
Merged

feat(sdk): support typed documents in http adapters#1566
toiroakr merged 2 commits into
mainfrom
feat/http-adapter-typed-document-node

Conversation

@dqn

@dqn dqn commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • HTTP adapter input handlers can now return generated typed GraphQL documents.
  • Variables are checked from the document type, and the shared output callback receives typed resp.data.

Example

import { createHttpAdapter } from "@tailor-platform/sdk";
import { GetUserDocument } from "../generated/graphql";

export default createHttpAdapter({
  name: "user",
  pathPattern: "/users/*",
  input: {
    get: (req) => ({
      query: GetUserDocument,
      variables: { id: req.path.split("/")[2] ?? "" },
    }),
  },
  output: (resp) => ({
    statusCode: 200,
    headers: { "content-type": "application/json" },
    body: JSON.stringify(resp.data?.user ?? null),
  }),
});

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b2851ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/create-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@tailor-platform/create-sdk@b2851ac
pnpm add https://pkg.pr.new/@tailor-platform/sdk@b2851ac

commit: b2851ac

@github-actions

This comment has been minimized.

@dqn
dqn force-pushed the feat/http-adapter-typed-document-node branch from b78247a to acd85bf Compare June 26, 2026 01:01
@github-actions

This comment has been minimized.

@dqn
dqn marked this pull request as ready for review June 26, 2026 01:17
@dqn
dqn requested a review from a team as a code owner June 26, 2026 01:17
@dqn
dqn requested a review from toiroakr June 26, 2026 01:17

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📖 Docs Quality & Consistency Check

✅ Docs are consistent with the implementation and contain no user-facing internal-detail leaks.

Checked areas:

  • HTTP adapter documentation (packages/sdk/docs/services/http-adapter.md) - new "Typed GraphQL Documents" section accurately describes the feature
  • HTTP adapter type definitions and JSDoc (packages/sdk/src/configure/services/http-adapter/http-adapter.ts) - exported types and function documentation are user-focused
  • Changeset description (.changeset/typed-http-adapter-documents.md) - concise and accurate
  • Implementation consistency - all documented features are correctly implemented:
    • TypedDocumentNode support in query field
    • Type inference for variables (required vs optional)
    • Type inference for resp.data in output handlers
    • Union types for multiple method handlers
    • HttpAdapterInputFn<Query> generic type parameter
  • Internal implementation details (bundler, __normalizeHttpAdapterGraphQLRequest, @​0no-co/graphql.web printer) are correctly kept internal and not mentioned in user-facing documentation

Re-run this check by adding the docs-check label to the PR.


return `import __adapter from ${JSON.stringify(absoluteSourcePath)};
const documentNormalizer = `import { print as __printHttpAdapterDocument } from ${JSON.stringify(graphqlPrinterModule)};
function __normalizeHttpAdapterGraphQLRequest(result) {
if (typeof result.query === "string") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If result is null or undefined, accessing result.query throws a TypeError.

Change the condition to if (!result || typeof result.query === "string").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b2851ac.

@toiroakr toiroakr assigned dqn and unassigned toiroakr Jun 26, 2026
@dqn
dqn requested a review from toiroakr June 27, 2026 03:05
@dqn dqn assigned toiroakr and unassigned dqn Jun 27, 2026
@github-actions

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (04c2ebb) #1566 (af9f0fd) +/-
Coverage 69.7% 69.7% +0.0%
Code to Test Ratio 1:0.4 1:0.4 -0.1
Details
  |                    | main (04c2ebb) | #1566 (af9f0fd) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          69.7% |           69.7% | +0.0% |
  |   Files            |            422 |             422 |     0 |
  |   Lines            |          15081 |           15086 |    +5 |
+ |   Covered          |          10516 |           10521 |    +5 |
- | Code to Test Ratio |          1:0.4 |           1:0.4 |  -0.1 |
  |   Code             |         102339 |          102424 |   +85 |
+ |   Test             |          45593 |           45603 |   +10 |

Code coverage of files in pull request scope (91.8% → 92.3%)

Files Coverage +/- Status
packages/sdk/src/cli/services/http-adapter/bundler.ts 92.2% +0.4% modified
packages/sdk/src/configure/services/http-adapter/http-adapter.ts 100.0% 0.0% modified

SDK Configure Bundle Size

main (04c2ebb) #1566 (af9f0fd) +/-
configure-index-size 20.14KB 20.32KB 0.18KB
dependency-chunks-size 47.71KB 47.71KB 0KB
total-bundle-size 67.85KB 68.03KB 0.18KB

Runtime Performance

main (04c2ebb) #1566 (af9f0fd) +/-
Generate Median 3,013ms 2,950ms -63ms
Generate Max 3,028ms 2,989ms -39ms
Apply Build Median 3,087ms 3,001ms -86ms
Apply Build Max 3,116ms 3,010ms -106ms

Type Performance (instantiations)

main (04c2ebb) #1566 (af9f0fd) +/-
tailordb-basic 36,391 36,617 226
tailordb-optional 3,841 3,841 0
tailordb-relation 6,012 6,012 0
tailordb-validate 2,566 2,566 0
tailordb-hooks 5,777 5,777 0
tailordb-object 12,136 12,136 0
tailordb-enum 2,462 2,462 0
resolver-basic 9,438 9,438 0
resolver-nested 26,125 26,125 0
resolver-array 18,201 18,201 0
executor-schedule 4,268 4,268 0
executor-webhook 907 907 0
executor-record 6,788 6,788 0
executor-resolver 4,417 4,417 0
executor-operation-function 899 899 0
executor-operation-gql 903 903 0
executor-operation-webhook 918 918 0
executor-operation-workflow 1,747 1,747 0

Reported by octocov

@toiroakr toiroakr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@toiroakr
toiroakr merged commit fb286e5 into main Jun 29, 2026
42 checks passed
@toiroakr
toiroakr deleted the feat/http-adapter-typed-document-node branch June 29, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants