webonyx/graphql-php is a comprehensive PHP implementation of the GraphQL specification, serving as a server-side library for parsing, validating, and executing GraphQL queries. It provides a full type system (ObjectType, InterfaceType, UnionType, EnumType, InputObjectType, ScalarType), a recursive-descent parser, an AST visitor infrastructure, a query validator with over 30 validation rules, and a reference executor that mirrors the GraphQL.js implementation. The library also includes a PSR-7-compatible server layer (StandardServer) for handling HTTP requests, along with optional promise adapters for async execution via ReactPHP or Amp. The architecture is library-oriented: clients build schemas programmatically or from SDL via BuildSchema, then execute queries through GraphQL::executeQuery() or the StandardServer. The type system uses lazy initialization (closures/callables) to handle circular references, and a type loader enables deferred schema composition. Notable design patterns include a rich AST visitor with enter/leave operations (including skip, stop, remove, edit), a synchronous promise adapter that enables DataLoader-like batching in synchronous PHP, and a modular validation rule system where each rule is a standalone visitor. The codebase demonstrates high craftsmanship with heavy use of static analysis (PHPStan), extensive unit tests ported from graphql-js, and performance benchmarks. While it is a port of the JavaScript reference implementation, it introduces PHP-idiomatic features such as attribute-based annotations (#[Description], #[Deprecated]) and per-schema scalar overrides.
This repository implements the GraphQL specification for Swift, providing a complete parsing, validation, and execution engine. It is a library intended to be consumed by server‑side Swift frameworks (e.g., Graphiti, graphql‑vapor) or any Swift project requiring GraphQL support. The architecture follows a layered design: a lexical analyzer and recursive‑descent parser produce an AST (Sources/GraphQL/Language/), a rich type system (Sources/GraphQL/Type/) supports all GraphQL types and directives, a validation layer (Sources/GraphQL/Validation/) implements over 20 spec‑required rules, and an execution engine (Sources/GraphQL/Execution/) resolves queries concurrently. Subscriptions are supported via Swift async sequences (Sources/GraphQL/Subscription/). The library also includes schema construction from SDL, schema printing, and a flexible Map value type for dynamic GraphQL values. In production, a client calls the top‑level `graphql()` function with a schema, a query string, and optional variables. The query is parsed, validated against the schema, and then executed field‑by‑field. Resolvers (provided by the schema) produce results that are serialized into a `GraphQLResult` with proper error handling. The library handles all GraphQL features: object types, interfaces, unions, enums, input objects, custom scalars, directives (`@deprecated`, `@specifiedBy`, `@oneOf`), and persisted queries. The test suite mirrors the reference JavaScript implementation and covers the Star Wars schema, introspection, federation, and edge cases. The codebase is well‑structured and follows best practices for Swift libraries: it uses Swift concurrency, Sendable annotations, and the `swift‑collections` package for ordered dictionaries. Several components are self‑contained and could be reused independently, such as the `Map` dynamic value type, the AST visitor infrastructure, and the printer. However, some deviations from the GraphQL spec remain (e.g., a handful of validation rules are commented out), and there is code duplication between `AnyCoder` and `MapCoder`. Force‑unwraps and some thread‑safety workarounds indicate areas that could be hardened. Overall, the library is production‑ready and actively maintained.