- What is ivome/graphql-relay-php used for?
- It is a framework-agnostic PHP helper library that adds Relay specification support on top of webonyx/graphql-php. It provides global object identification, cursor-based connection and pagination helpers, and mutation scaffolding with client mutation IDs. You call its static helpers inside your type definitions and resolvers when you need a Relay-compliant schema for Relay or Apollo clients that use normalized caches and node refetching.
- Does ivome/graphql-relay-php work with Laravel?
- It is not a Laravel-specific package: there is no service provider, config file, facade, or migration. In a Laravel app you use it indirectly through your GraphQL layer, typically Lighthouse or a hand-rolled webonyx/graphql-php controller, calling its static helpers from type definitions and resolvers. Installation is just a Composer require, so the real work is deciding where the helpers live in your codebase so they are not scattered across resolvers.
- How do I install ivome/graphql-relay-php with Composer?
- Run composer require ivome/graphql-relay-php and confirm that webonyx/graphql-php is installed at a version the package supports. There is nothing to publish or register, and no configuration step, because every helper is a static function. After installing, run a quick smoke test that resolves a node and a connection to confirm the helpers behave as expected.
- Which webonyx/graphql-php versions does it support?
- The last tagged release was 2021-04-24, so compatibility with webonyx/graphql-php v15 and newer is not officially verified. Check the composer.json constraint before adding it and test against the exact graphql-php major you plan to run in production. If you need v15+ with PHP 8.2 or 8.3, budget a short spike to confirm nothing breaks before committing.
- Does ivome/graphql-relay-php work with PHP 8.2 and PHP 8.3?
- There is no evidence of active verification, since the package has not had a release since April 2021. It is a small collection of static helpers, so it may run fine on modern PHP, but you should run your own smoke tests and static analysis on PHP 8.2 and 8.3 before depending on it. Treat it as effectively unmaintained and be prepared to fork or vendor it if you hit incompatibilities.
- How do I build a Relay connection from a PHP array?
- Use connectionFromArray with your items and the connection args, and it handles slicing, edge cursors, pageInfo, and the count. For anything backed by a database, use connectionFromArraySlice instead and pass your own LIMIT/OFFSET or keyset window so you only hydrate one page. Avoid connectionFromArray and cursorForObjectInConnection on large tables, because both work against an already-loaded array and cursorForObjectInConnection performs an O(n) scan.
- How do toGlobalId and fromGlobalId work, and what are the risks?
- toGlobalId encodes a type name and ID pair into an opaque base64 string that clients use for node refetching, and fromGlobalId reverses that into type and ID. Because clients persist these global IDs in their caches, changing the encoding or the type-name mapping is a breaking API change that is hard to diagnose and expensive to migrate. Keep the codec stable, avoid leaking it into unrelated layers, and have a versioning story before you alter it.
- Is ivome/graphql-relay-php redundant if I already use Lighthouse?
- Lighthouse already ships native Relay support, including directives like @globalId and @node plus cursor-based pagination, which covers most common needs. Audit that native support first and only add this package if you hit a concrete gap. Running both can produce inconsistent global ID encoding and duplicated connection logic across your schema.
- How should I test Relay connections and mutations built with this package?
- Because the helpers are pure static functions, you can unit test toGlobalId/fromGlobalId round trips and connectionFromArray output without booting a server. For end-to-end coverage, run graphql-php's execute() against your schema in PHPUnit and assert edge cursors, pageInfo flags, and that clientMutationId is echoed back. Make sure tests do not rely on connectionFromArray in paths that will hit large tables in production, or they can mask full-table scans.
- Is ivome/graphql-relay-php still maintained, and what are the alternatives?
- It is effectively single-maintainer with roughly 270 GitHub stars and a last release in April 2021, and the repository provenance is listed as unknown, which is a governance concern for a package that encodes global IDs. The Relay spec itself is stable, so feature-complete is a defensible reading, but current graphql-php and PHP compatibility is unverified. Alternatives are Lighthouse's built-in Relay directives, another maintained Relay helper package, or owning roughly 300 to 500 lines yourself for the ID codec, cursor codec, connection builder, and node registry.