Skip to content

Add Godot platform support and GDScript SDK generator#1527

Open
NIKHIL0VERMA wants to merge 61 commits into
appwrite:masterfrom
NIKHIL0VERMA:feat/godot-support
Open

Add Godot platform support and GDScript SDK generator#1527
NIKHIL0VERMA wants to merge 61 commits into
appwrite:masterfrom
NIKHIL0VERMA:feat/godot-support

Conversation

@NIKHIL0VERMA
Copy link
Copy Markdown

@NIKHIL0VERMA NIKHIL0VERMA commented May 11, 2026

What does this PR do?

This PR adds support for the Godot game engine and introduces GDScript as a new SDK generation target.

The generated SDK is designed for Godot 4.x projects and enables direct integration with Appwrite services using GDScript

Godot-specific implementation details

  • Used a global Appwrite autoload singleton to expose services in a more idiomatic Godot-style API instead of requiring separate exports/imports for every service
  • Some method names are changed to handle GDScript keyword conflicts. For example:
    • Appwrite.account.get() conflicts with a built-in GDScript method
    • Replaced with Appwrite.account.xget()

The generated SDK is designed for Godot 4.x projects and enables direct integration with Appwrite services using GDScript.

Test Plan

The Godot SDK generates with sample project which can be opened directly inside the Godot Engine for integration testing.

The generated project also includes test files compatible with the GUT testing framework. Tests can be executed after installing GUT from the Godot Asset Library. If GUT is not installed, parsing error of test files can be ignored safely.

Automated validation

Added CI and automated SDK validation for generated Godot and GDScript targets.

Personally tested on:

  • Ubuntu 22.04
  • Kernel: 6.5.0-45-generic
  • Godot Engine: 4.6.2.stable.official.71f334935

Verified:

  • Client initialization
  • ping requests
  • Anonymous account creation
  • Email/password account creation
  • Email/password login
  • Logout current session
  • Account session persistence
  • Database CRUD operations
  • Storage CRUD operations
  • Multipart file uploads
  • Large file upload (>5mb)
  • Async request handling
  • Error handling
  • JSON response parsing and serialization

Have you read the Contributing Guidelines on issues?

yes

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 11, 2026

Greptile Summary

This PR introduces GDScript and Godot 4.x as new SDK generation targets, adding two new language classes (GDScript.php, Godot.php), a full set of Twig templates for client/service/model/util layers, and CI test harnesses for both platforms. It is a heavily revised second iteration that has addressed a large number of previously-identified bugs.

  • GDScript (server-side): HTTP client with chunked-upload support, redirect-based webAuth flow, model serialization with prefixed class names, and correct Variant = null optional-parameter handling. All previously reported crashes, status-code key mismatches, node leaks, and class-name collisions are now resolved.
  • Godot (client-side): Extends GDScript with a TCPServer OAuth2 callback handler, cookie persistence, and a scene/menu scaffold. The call_web_api now correctly frees the OAuth node, cleanup() stops the TCP server, and failure redirects are wrapped in AppwriteException via _handle_response.
  • Test infra: GDScript4Test.php and Godot4Test.php copy test resources without the trailing-slash bug, and the Godot test's intentional omission of OAuth responses is explained by the CI environment lacking GUI support.

Confidence Score: 4/5

The PR is largely ready to merge — the major bugs from prior review rounds have all been resolved. The two remaining notes are low-impact edge cases that won't affect normal usage.

This is a 96-file new SDK addition that has gone through significant revision. The core HTTP, chunked-upload, OAuth, model, and service layers are all in much better shape than previous iterations. Two minor items remain: cleanup() in the OAuth handler not disabling _process, and _call_chunked silently returning an empty dictionary for a 0-byte file. Neither affects normal operation.

templates/godot/addons/utils/oauth2.gd.twig (cleanup housekeeping) and templates/gdscript/addons/utils/client.gd.twig (_call_chunked zero-size edge case); both also have identical counterparts in the godot client template.

Important Files Changed

Filename Overview
src/SDK/Language/GDScript.php New GDScript SDK language class with getFiles(), getTypeName(), getParamDefault(), and filter definitions — previous issues (scopoe typo, duplicate test_query entries, TYPE_INTEGER default of '0.0') are now fixed.
src/SDK/Language/Godot.php Godot client-side SDK extending GDScript; adds cookie persistence, OAuth2 utils, and scene files. Previous duplicate test_query.gd entry is resolved.
templates/gdscript/addons/utils/client.gd.twig HTTP client template for GDScript; previous crashes on Dictionary returns, status-code key mismatches, and HTTPRequest node leaks are all fixed. Remaining edge case: _call_chunked with a 0-byte file silently returns {}.
templates/godot/addons/utils/client.gd.twig Godot client-side HTTP client; call_web_api now correctly queue_frees the oauth node, statusCode casing is consistent, and large-file HTTP node leak is fixed.
templates/godot/addons/utils/oauth2.gd.twig TCPServer OAuth2 callback handler; 'JavaScript' feature tag corrected to 'web', crash on missing body key fixed with .get(), failure URL now emitted with statusCode 401. Minor: cleanup() omits set_process(false).
templates/gdscript/addons/models/model.gd.twig Model deserialization template; nested model references now correctly prefixed with SDK title, null guard on untyped fallback prevents typed-property assignment errors.
templates/gdscript/addons/utils/service.gd.twig Base service utility template; _handle_response correctly inspects statusCode and wraps errors as AppwriteException, including the network-error (statusCode==0) and non-Dictionary body paths.
templates/gdscript/addons/services/service.gd.twig Generated per-service template; optional parameters use Variant = null with null-guard omission, float type check now also accepts int via TYPE_INT check.
templates/gdscript/addons/appwrite.gd.twig Autoload singleton template; FileAccess.open() null-check added, ping() now properly inspects statusCode and returns AppwriteException on failures.
tests/GDScript4Test.php GDScript CI test harness; resource copy command no longer has trailing slash issue — tests/resources directory is correctly placed at tests/sdks/gdscript/tests/resources/ matching res://tests/resources/.
tests/Godot4Test.php Godot CI test harness; matches GDScript test structure. OAUTH_RESPONSES intentionally omitted (acknowledged as CI limitation requiring GUI).

Reviews (27): Last reviewed commit: "refactor: removed rendering section from..." | Re-trigger Greptile

Comment thread src/SDK/Language/GDScript.php
Comment thread src/SDK/Language/GDScript.php
Comment thread src/SDK/Language/GDScript.php
Comment thread src/SDK/Language/GDScript.php
Comment thread src/SDK/Language/GDScript.php
Comment thread src/SDK/Language/Godot.php Outdated
Comment thread src/SDK/Language/GDScript.php
Comment thread templates/godot/addons/utils/client.gd.twig
Comment thread templates/gdscript/addons/models/model.gd.twig
Comment thread templates/godot/addons/utils/client.gd.twig
@NIKHIL0VERMA NIKHIL0VERMA marked this pull request as draft May 11, 2026 17:24
@NIKHIL0VERMA NIKHIL0VERMA marked this pull request as ready for review May 12, 2026 16:00
Comment thread templates/godot/addons/input_file.gd.twig Outdated
@NIKHIL0VERMA NIKHIL0VERMA marked this pull request as draft May 19, 2026 15:08
Initial implementation of Godot support:
- template-based generation for services and client
- preliminary docs example template
- mirrors structure of existing SDKs (services/, enums/, models/)
- not fully functional yet (runtime + DX pending)
- Refactored Godot SDK output directory structure to follow the addons/appwrite convention for plugins.
- Migrated call_api in client.gd from an HTTPClient polling loop to a native, async HTTPRequest node architecture.
- Added appwrite.gd plugin singleton and updated plugin.cfg / plugin.gd generation logic.
- Implemented robust error handling by parsing HTTP responses into typed AppwriteExceptions.
- Fixed docs/example.md.twig template for correct GDScript method invocation and autoload reference.
- Enhanced global state management by defaulting endpoint and project settings directly from ProjectSettings overrides.
- corrected type resolution for models, enums, arrays of models, and arrays of enums
- added .env support for loading client configuration
- reduced global namespace pollution by removing class_name from enums
- improved enum system to support string-based values (Appwrite-compatible vs Godot int enums)
- refactored models to use FIELD_MAP for better readability and mapping
- added proper import handling for enums and nested models
- updated plugin to load only when enabled (not immediately after installation)
- centralized network calls and exception handling for better debugging
- removed deprecated and duplicate methods from generated services
- updated services to use centralized network caller
- Fix enum handling to use String-based representation instead of invalid typed enums(Godot internal use int representation)
- Resolve incorrect default value mapping for integer parameters (e.g. [] assigned to int in storage)
- Improve parameter type inference in codegen for arrays, enums, and primitives
- Fix Godot HTTPRequest lifecycle issue caused by calling request before node enters scene tree
- Replace deferred node attachment pattern with proper add_child timing
- Improve robustness of generated GDScript service methods and parameter defaults
- refactor Appwrite singleton to delegate all config to client
- centralize environment variable handling with _apply_env()
- add dynamic header setters using spec.global.headers
- support additional env configs (JWT, session, locale, mode, self-signed)
- enforce single client instance via autoload (singleton pattern)
- cleared Appwrite singleton namespace by removing raw classes
Changed typed return values to Variant so errors can be returned to the SDK user instead of causing runtime failures in services.
- Generate inline documentation for all service methods
- Add parameter description using [param] annotation
- Include return type details helping in better type casting
- Automatically annotate deprecated APIs with @deprecated
- Format docs using Godot BBCode for editor integration
- Add explicit typing for services to enable autocomplete and navigation
- Replace inline preload().new() with typed constants and instances
- Introduce class_name to enable doc indexing
- Fix missing method hints for chained calls (e.g., Appwrite.account.*)
- Add description for services and examples
- Exposed Enums through Appwrite autoload
- Ensure documentation appears in editor tooltips along with method hints
- Added Appwrite icon to Godot generated docs
…ethods

- Updated service templates to use 'Variant = null' for all optional parameters.
- Added runtime type validation to ensure passed values match the intended types.
- Included explicit type hints in documentation comments using [Type] notation.
Comment thread templates/godot/addons/utils/client.gd.twig
Comment thread templates/godot/addons/utils/service.gd.twig Outdated
Comment thread templates/gdscript/addons/utils/client.gd.twig
Comment thread templates/gdscript/addons/utils/client.gd.twig
Comment thread templates/gdscript/addons/appwrite.gd.twig
Comment thread templates/gdscript/addons/models/model.gd.twig
Comment thread templates/godot/addons/utils/oauth2.gd.twig
Comment thread templates/gdscript/addons/utils/service.gd.twig Outdated
Comment thread templates/gdscript/addons/utils/client.gd.twig
Comment thread templates/gdscript/addons/utils/client.gd.twig Outdated
Comment thread templates/gdscript/addons/utils/client.gd.twig Outdated
- Escape web OAuth URL when calling JavaScriptBridge.eval
- Parse OAuth failure query params for clearer error messages
- Map HTTPRequest failure codes to human-readable messages
- Add FileAccess existence/open/read guards in InputFile.get_data()
- Normalize network failures to statusCode=0 and use error key
@NIKHIL0VERMA NIKHIL0VERMA force-pushed the feat/godot-support branch 2 times, most recently from 27a2af8 to 3b1db64 Compare May 27, 2026 16:33
Comment thread tests/GDScript4Test.php Outdated
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.

1 participant