Skip to content

Task: support json field#64

Merged
roneli merged 12 commits intomasterfrom
task-support-json-field
Dec 27, 2025
Merged

Task: support json field#64
roneli merged 12 commits intomasterfrom
task-support-json-field

Conversation

@roneli
Copy link
Owner

@roneli roneli commented Dec 10, 2025

This pull request introduces comprehensive support for working with PostgreSQL JSONB columns in FastGQL, including a new @json directive for typed JSON fields, efficient nested field selection, and advanced filtering capabilities. The changes add documentation, example code, and database setup to demonstrate these features, making it much easier to query and filter JSON data in a type-safe and performant way.

JSON Field Selection and Filtering Enhancements

  • Added the @json directive for marking GraphQL fields as typed JSON stored in PostgreSQL JSONB columns, enabling type-safe filtering and efficient nested field selection in queries. Documentation now explains both the directive and its usage, with examples for both typed and dynamic JSON approaches. [1] [2]
  • Introduced detailed documentation and examples for selecting nested fields from JSON columns, including setup instructions, test queries, and expected results. This covers scalar selection, deep nesting, and mixed queries, with clear explanations of how FastGQL leverages PostgreSQL operators for performance. [1] [2]

JSON Filtering Operators

  • Documented specialized filtering operators for JSON fields, including the MapComparator input type for dynamic JSON and the MapPathCondition for JSONPath-based filtering. Examples and validation rules for JSON paths are provided, covering containment, path-based conditions, and null checks. [1] [2]

Example Setup and Supporting Files

  • Added a complete example in the examples/json/ directory, including SQL schema and test data for products with JSONB columns, GraphQL schema definitions, README with setup and queries, and configuration files for code generation and GraphQL tooling. [1] [2] [3] [4] [5]

These changes provide a robust foundation for working with JSONB columns in FastGQL, making it easy to define, query, and filter structured and dynamic JSON data directly from your GraphQL API.

@vercel
Copy link

vercel bot commented Dec 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
fastgql-by75 Ready Ready Preview, Comment Dec 27, 2025 7:21pm

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces comprehensive support for working with PostgreSQL JSONB columns in FastGQL, enabling type-safe filtering and efficient nested field selection for JSON data through the new @json directive.

Key Changes:

  • Added @json directive for typed JSON fields with automatic filter input generation
  • Implemented JSONPath-based filtering for dynamic JSON using MapComparator and MapPathCondition
  • Created efficient nested field selection using PostgreSQL's native -> operator and jsonb_build_object

Reviewed changes

Copilot reviewed 36 out of 40 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/schema/fastgql.graphql Added @json directive definition, IDComparator, MapComparator, and MapPathCondition input types
pkg/schema/schema.go Added jsonDirectiveName constant for directive registration
pkg/schema/fastgql.go Registered @json directive in FastGQLDirectives list
pkg/schema/filter.go Implemented filter input generation for JSON types with createJsonTypeFilterInput function
pkg/schema/filter_test.go Added comprehensive test coverage for JSON filter generation
pkg/execution/builders/sql/json.go Implemented JSONPath expression building, path validation, and field selection logic
pkg/execution/builders/sql/json_test.go Added extensive test coverage for JSON filtering and path validation
pkg/execution/builders/sql/builder.go Integrated JSON field building and filtering into query builder
pkg/execution/builders/sql/builder_test.go Added tests for JSON filtering and field selection SQL generation
pkg/execution/builders/field.go Added TypeJson field type for JSON fields
pkg/execution/e2e_test.go Added E2E tests for typed and Map JSON filtering
examples/json/* Complete example with schema, SQL setup, resolvers, and documentation
docs/src/content/docs/schema/directives.md Documented @json directive with usage examples
docs/src/content/docs/schema/operators.md Documented MapComparator and MapPathCondition operators
docs/src/content/docs/queries/queries.md Added JSON field selection documentation
docs/src/content/docs/queries/filtering.mdx Added comprehensive JSON filtering documentation with examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@roneli roneli requested a review from Copilot December 16, 2025 19:46
@roneli roneli added the enhancement New feature or request label Dec 16, 2025
@roneli roneli linked an issue Dec 16, 2025 that may be closed by this pull request
19 tasks
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 41 out of 47 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

.github/workflows/coverage.yml:1

  • Deleting the test coverage workflow may reduce visibility into test coverage changes. Ensure test coverage is still tracked through another mechanism.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@roneli roneli merged commit 25cb503 into master Dec 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FastGQL first version roadmap

2 participants