Skip to content

V3#75

Open
schettn wants to merge 187 commits intomainfrom
v3
Open

V3#75
schettn wants to merge 187 commits intomainfrom
v3

Conversation

@schettn
Copy link
Copy Markdown
Contributor

@schettn schettn commented Feb 19, 2025

This pull request includes significant updates to the @getcronit/pylon packages, introducing major changes and new features, as well as some minor improvements and bug fixes. The most important changes include the integration of @getcronit/pylon-builder into @getcronit/pylon-dev, enhancements to the authentication system, and improvements to the plugin system.

Major Changes:

  • Integration of @getcronit/pylon-builder into @getcronit/pylon-dev:

    • Removed the pylon-builder package.
    • The builder now uses esbuild watch mode for faster and more efficient development.
    • Implemented pm2 for process management, restarting the server automatically after builds, and logging with consola.
  • Overhaul of the authentication system:

    • Introduced the useAuth plugin, which automatically sets up authentication routes (/auth/login, /auth/callback, /auth/logout), manages token cookies, and enhances role-based route protection.
    • Updated documentation to reflect the new authentication system and its configuration. [1] [2]

Minor Changes:

  • Enhancements to the plugin system:

    • Extended the plugin system with setup, middleware, and build functions.
    • Integrated the viewer via a built-in useViewer plugin.
    • Custom plugins can now access the app instance and register routes, middleware, and custom build steps.
  • New usePages plugin:

    • Added support for file-based (Fullstack React) routing.
  • Option to disable playground and introspection:

    • Added a configuration option to disable the playground and introspection in the Pylon configuration.

Patch Changes:

  • Fixes and improvements in create-pylon:

    • Used consola for clearer interactive prompts and logs.
    • Removed certain flags in favor of the GQty CLI.
    • Improved package manager detection and dependency installation.
    • Enhanced error handling and messaging.
  • Bug fix:

    • Fixed broken field descriptions in schema parsing.

These updates improve the overall functionality, performance, and developer experience of the @getcronit/pylon packages.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 19, 2025

🦋 Changeset detected

Latest commit: 74ba3bf

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

This PR includes changesets to release 3 packages
Name Type
@getcronit/pylon-dev Major
@getcronit/pylon Major
create-pylon Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 19, 2025

🚀 Snapshot Release (canary)

The latest changes of this PR are available as canary on npm (based on the declared changesets):

Package Version Info
create-pylon 1.1.5-canary-20260508115545.74ba3bff3f7ade973010148205bb756b3e5642cc npm ↗︎ unpkg ↗︎
@getcronit/pylon 3.0.0-canary-20260508115545.74ba3bff3f7ade973010148205bb756b3e5642cc npm ↗︎ unpkg ↗︎
@getcronit/pylon-dev 2.0.0-canary-20260508115545.74ba3bff3f7ade973010148205bb756b3e5642cc npm ↗︎ unpkg ↗︎

enable source maps for client and server builds and update external dependencies
This fixes the the documentation of type fields (e.g. interfaces) in the
schema parser.
Previously, the return type of the property was used to determine the
description of the field. If a type property used the `Date` type,
the description of the `Date` type was used instead of the actual description
of the field.

This commit changes the behavior to use the property symbol instead of the
return type of the property.

closes #76
Nico Schett added 30 commits March 16, 2026 17:36
…solvers

Previously, `PatchSchema` aggressively unwrapped function signatures down to their awaited return types. This caused nested resolvers (e.g., `collections.nodes[0].products`) to incorrectly lose their callable signatures and argument definitions.

This update:
- Modifies `PatchSchema` to infer and retain original arguments (`(...args: infer Args)`), applying the schema patch exclusively to the function's return type.
- Updates `NeedsMap` to safely unwrap function signatures, ensuring nested field selections (`needs`) can still be accurately mapped to the underlying return types.
…s and adjust scalar type resolution in `getType`.
Previously, `wrapResolver` failed to map data correctly when remote
schemas returned fields under their alias keys instead of schema keys.
Furthermore, mixing unaliased and aliased queries for the same field
(e.g., `products` and `a: products`) caused the execution to eagerly
resolve using the schema key, dropping the aliased data.

This update modifies the complex node resolution step to scan
`childNodes` for the presence of any aliases. If aliases are found,
it defers to a dynamic resolver function. At execution time, this
function dynamically prioritizes looking up the specific `aliasKey`
from the resolved data object before falling back to the standard
`schemaKey`.

This ensures robust compatibility with underlying engines when
delegating heavily aliased queries to remote schemas.
Previously, if a user provided a patch function in `PylonGateway` but
did not explicitly spread the original `data` object in their return
statement, any dynamically aliased fields returned by the remote schema
were silently dropped. This caused deeply nested aliased queries to fail
and return null during downstream execution.

This update modifies `PylonPatchTransform` to automatically merge the
original `processedData` with the `patchedData` returned by the user's
patch function. This guarantees that all underlying remote data and
aliases are strictly preserved for the local GraphQL engine to resolve,
regardless of how the patch function is written.
- Add support for generating indexable multi-file feeds.
- Support standard cache revalidation exports for caching integration.
- Introduce MetadataRoute namespace to bundle nested sitemap types.
- Automatically expand relative paths into absolute URLs using the request origin.
- Replaced default `delegateToSchema` variable generation with a custom `InlineArgsTransform`.
- Arguments are now parsed from flat JavaScript objects directly into inline GraphQL AST nodes.
- This bypasses rigid remote wrapper types (like `{ input: ... }`) in the variables payload, allowing for developer-friendly, flattened local function signatures.
- Integrated a `TypeInfo` traversal pass during AST injection to automatically detect and coerce string AST nodes into `Kind.ENUM` nodes based on the remote schema. This resolves `GRAPHQL_VALIDATION_FAILED` errors when passing string representations of enums to strict remote graphs.
…d arguments, and fix scalar type checking.
- Added `Argument` and `ObjectField` visitors to `InlineArgsTransform`.
- When an operation defines an optional variable that is absent from the variables payload, the visitor now returns `null` to completely strip the argument or field from the AST tree.
- This prevents the remote GraphQL server from throwing undefined variable errors when encountering orphaned variable nodes (e.g., `first: $missingVar`).
- Ensures seamless fallback behavior for omitted arguments while preserving full variable inlining.
- Extract and apply `statusCode` from React Router context in setup
- Add 404 loaders to internal catch-all routes in build utils
was broken due to change in early return for JSON requests
…tic analysis

- Migrated from the legacy prop-injected "data skeleton" model to a robust `useData` hook that enforces React Suspense for a more deterministic loading experience.
- Implemented `use-data-static-analyzer` to perform deep project-wide analysis, extracting all possible GraphQL requirements—including conditional fields across the entire component tree—into automatic `prepare` blocks.
- Eliminated partial render issues and manual pre-fetching by pairing static requirement extraction with Suspense, ensuring components only render when all potential data paths are fulfilled.
- Replaced brittle prop-based refetching with a globally scoped `useDataRefetch` hook for targeted, operation-based cache invalidation.
- Introduced `DataQueryProvider` and `useDataQuery` for scoped hydration, resolving browser-side hydration mismatches and cache collisions.
- Hardened the build-time transformer with AST-based injection to robustly support merging `prepare` blocks into both literal and dynamic `useData` configurations.
- Fixed circular dependency bugs and internal context duplication by migrating core state to direct internal modules.
- Enabled `splitting: true` in esbuild configuration to keep dynamic imports isolated in separate chunks.
- Refactored `usePages` plugin types into a standalone `types.ts` file to prevent accidental loading of React-heavy component logic during type discovery.
- Ensured `dist/index.js` remains a lightweight entry point without mandatory React runtime requirements.
…functions

- Updated the static analyzer's generatePrepare logic to use optional chaining (?.) for all property accesses, array mappings, and function calls.
- This hardens the injected code against runtime errors when encountering null or undefined values in intermediate data paths during initial data fetching.
- Updated unit and integration tests across selectors-to-prepare.test.ts, build.test.ts, and integration.test.ts to match the new robust output format.
- Injected a <Suspense> boundary into the generated WithLoaderDataWrapper in app-utils.ts. This prevents full route remounts when useData suspends, preserving the stability of the pageClient and its cache.
- Enabled pageClient.useHydrateCache in the generated client code to correctly apply SSR snapshots.
- Cleaned up debug console.log statements in app-utils.ts and use-data.ts.
- Adjusted the pruning logic sequence to ensure consistent component lifecycle behavior.
- Introduced StaticAnalysisManager to deduplicate ts-morph project initialization and query analysis between client and server builds.
- Implemented content-based hashing and a per-session cache to bypass expensive AST parsing on unchanged files.
- Added robust dependency tracking that records all accessed files during AST traversal (including child components and imports) and reports them to esbuild via watchFiles.
- Updated coreAnalyze to handle recursive file access tracking and fixed existing test regressions.
- Refactored the esbuild plugin to share a single manager instance across build contexts, resulting in ~50-75% faster rebuild times.
…nt-side redirects

Refactors the SSR data fetching and redirect logic to improve performance and
alignment with React Router's data pipeline.

- **Server-side Loaders**: Replaced the dynamic `@getcronit/pylon` import hack with
  React Router's `requestContext`. Loaders now receive `pagesContext` directly
  via the `context` parameter on the server.
- **Optimized Redirect Handling**: Introduced the `X-Pylon-Redirect` header for
  client-side navigation requests. This allows the server to signal redirects
  without using HTTP 302, preventing the browser's `fetch()` from automatically
  following the redirect and wasting a full server round-trip.
- **Native Error Handling**: Errors during GQty's `prepareReactRender` are now
  injected into `staticHandlerContext.errors`, allowing React Router to
  render the appropriate `errorElement` natively.
- **Cleanup**: Consolidated redirect and error handling logic in both the
  server-side setup and the isomorphic loader utility.
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.

Unknown package manager Pylon’s New Pages Router – Full-Stack Support Coming! Feedback Wanted!

2 participants