-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/graphql API Integration with Strawberry #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
OJEM22
wants to merge
7
commits into
main
Choose a base branch
from
feature/graphql-integration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement comprehensive GraphQL API for GTFS core entities with nested queries, pagination, and geo-spatial search capabilities. Schema and Resolvers: - Define GraphQL types for Stop, Route, Trip, StopTime - Add types for Calendar, GeoShape, Agency, GTFSProvider - Implement relationship resolvers for nested queries: * routes → trips → stops * stops → routes → stop_times * trips → route → service → stop_times - All resolvers use Django ORM with select_related/prefetch_related Pagination: - Implement Connection pattern with PageInfo - Pagination for: agencies, stops, routes, trips, stop_times - PageInfo includes: has_next/previous, cursors, total_count, page numbers Additional Features: - Geo-spatial search: stops_near(lat, lon, radius_km) using PostGIS - GTFS code lookups: agency_by_code, stop_by_code, route_by_code, trip_by_code - Filtered queries: routes_by_agency, trips_by_route, stop_times_by_trip/stop - Performance optimizations for nested queries Test Coverage: - Extended fixtures for Route, Calendar, Trip, StopTime - Query execution and validation tests - Schema conformance verification - Endpoint accessibility tests Issue #35: GraphQL Base Setup + Schema and Resolvers for Core Models
Update lock file to include GraphQL packages after rebase: - graphql-core 3.2.7 - lia-web 0.2.3 - strawberry-graphql 0.285.0 - strawberry-graphql-django 0.67.0 This completes the dependency resolution for Issue #35 GraphQL integration.
Rename package from gql_schema to graphql for consistency with project naming conventions (api, alerts, gtfs, etc.) and convert to proper Django app. Changes: - Rename gql_schema/ → graphql/ directory - Create graphql/apps.py with GraphqlConfig class - Update graphql/__init__.py with app config and documentation - Add graphql.apps.GraphqlConfig to INSTALLED_APPS in settings - Update all imports (datahub/urls.py, demo_graphql.py) Benefits: - Consistent with project naming (no underscores, no abbreviations) - Proper Django app structure (recognized by manage.py commands) - Better documentation and discoverability - Can have migrations/models/management commands if needed later - More professional Django convention Addresses feedback to make GraphQL its own app.
Add complete documentation for GraphQL API implementation including README with full API reference and DEMO_QUERIES with ready-to-use examples. Documentation includes: - Complete API overview and quick start guide - 8 GraphQL type definitions with all fields and relationships - 20+ query examples covering all resolver patterns - Pagination, geographic search, and nested query examples - Integration examples (Python, JavaScript, cURL) - Testing guide and troubleshooting section - Architecture and technology stack details - GraphQL vs REST comparison Demo queries file provides: - 20 ready-to-paste queries for GraphiQL testing - Basic queries (hello, agencies, stops, routes, trips) - Geographic queries (stops_near with different radii) - Nested queries (route→trips→stops, stop→schedule) - Complex dashboard queries - Performance testing queries - Field selection demonstrations - Testing checklist and modification tips Benefits: - Self-service documentation for API users - Quick testing and validation - Presentation-ready examples - Integration guidance for developers
BREAKING: Rename GraphQL Django app from 'graphql' to 'gql' to prevent import collision with Python's graphql-core library. Issue: When starting Docker containers, Django failed to import strawberry_django because the 'graphql' app name conflicted with the 'graphql' package from graphql-core (Strawberry's dependency). This caused import errors during Django setup. Root cause: Python's module resolution found our 'graphql' Django app instead of the 'graphql' package from graphql-core, breaking Strawberry's imports. Solution: Rename app to 'gql' (short, clear, no conflicts): - graphql/ → gql/ directory - GraphqlConfig → GqlConfig class - Update all imports and references - Update documentation Changes: - Rename directory: graphql/ → gql/ - gql/apps.py: GraphqlConfig → GqlConfig, name='gql' - gql/__init__.py: Update default_app_config path - datahub/settings.py: graphql.apps.GraphqlConfig → gql.apps.GqlConfig - datahub/urls.py: from graphql.schema → from gql.schema - demo_graphql.py: Update import path - gql/README.md: Update all references to app name and paths - gql/DEMO_QUERIES.md: No changes needed (queries unchanged) Benefits: - Resolves Docker startup error - No naming conflicts with Python packages - Still clear and concise (gql is common abbreviation for GraphQL) - Consistent with commit scope naming convention Fixes Docker import error that prevented containers from starting.
…tion - Create CHANGELOG.md following Keep a Changelog format - Document GraphQL API feature in [Unreleased] section - Add GraphQL API section to README with quick example - Update Application Structure and Project Structure to include gql app - Comprehensive technical implementation and dependency documentation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Implements a comprehensive GraphQL API for querying GTFS transit data using Strawberry GraphQL. This provides a modern, flexible alternative to the REST API with support for nested queries, field selection, pagination, and geographic search. The implementation includes 8 GraphQL types covering all major GTFS entities, 20+ query resolvers, comprehensive documentation (750+ lines), demo queries, and a full test suite (219 lines).
Type of Change
Transportation Context
Testing
gql/tests.py(219 lines)Test Execution:
python manage.py test gqlTest Coverage:
Documentation
gql/README.md(750+ lines)TRL Impact
Current TRL: 6 → New TRL: 6 (no change)
Justification: This feature adds a new API interface but does not fundamentally change the system's technology readiness level. The GraphQL API provides an alternative query interface to existing GTFS data without modifying core transit data processing capabilities. While it enhances developer experience and query flexibility, it represents an incremental improvement rather than a readiness level advancement.
Detailed Changes
New Features
GraphQL API (
/gql/endpoint)stopsNear)select_related()andprefetch_related()Documentation
gql/README.md(750+ lines)gql/DEMO_QUERIES.mdCHANGELOG.md(NEW)README.mdUpdatesTest Suite
gql/tests.py(219 lines)Technical Implementation
Schema Architecture
gql/schema.py: Strawberry Schema definition with Query type registrationgql/types.py(271 lines): Strawberry Django model types with field mappings, custom pagination types (Connection, PageInfo), relationship fieldsgql/queries.py(265 lines): Query resolvers optimized with Django ORMDjango Integration
gql/apps.py: Django app configurationdatahub/settings.py: Addedgql.apps.GqlConfigto INSTALLED_APPSdatahub/urls.py: Added GraphQL endpoint routingBug Fixes
graphql/directory togql/to avoid import collision with Python'sgraphql-corelibrary (dependency of Strawberry)Dependencies Added
strawberry-graphql==0.285.0- GraphQL schema definition librarystrawberry-graphql[django]==0.285.0- Django integration for Strawberryuv.lockwith new dependencies and dependency treeConfiguration
/gql/Impact on System
Positive Impacts
No Breaking Changes
How to Test
Access GraphiQL Interface
Run Test Suite
Example Queries
Basic Query:
Geographic Search:
Nested Query:
Integration Testing
Python:
References
Commits in This Branch
78c9634- docs(gql): add CHANGELOG and update README with GraphQL API documentation7726886- fix(gql): rename graphql app to gql to avoid naming conflict6a4bef8- docs(gql): add comprehensive documentation and demo queries5b920ae- refactor(gql): rename gql_schema to graphql and convert to Django app96ad2c1- chore(gql): update uv.lock with Strawberry GraphQL dependencies3e5f6fd- feat(gql): complete GraphQL schema with GTFS core models and pagination145f7d1- feat(gql): add GraphQL support with Strawberry Django integrationChecklist
Reviewers: Please Verify
http://localhost:8000/gql/and verify interactive interface workspython manage.py test gql- all tests should passgql/README.mdfor completeness and accuracygql/DEMO_QUERIES.mdin GraphiQLstopsNearquery with sample coordinatespageandpageSizeparametersFuture Enhancements
Ready for Production: ✅ Yes
Backward Compatible: ✅ Yes
Breaking Changes: ❌ None
Documentation Complete: ✅ Yes