The `graphql-ruby-client` is a JavaScript client library specifically designed to integrate with `graphql-ruby` servers. It facilitates frontend interactions by generating JavaScript modules from `.graphql` query, mutation, and subscription files, which are then consumed by popular client-side GraphQL libraries such as Apollo Client, Relay, or urql. Currently at version 1.14.9, the package demonstrates an active, incremental release cadence focused on bug fixes and feature enhancements, with the latest update being a couple of months ago. Its key differentiator lies in its tight integration with `graphql-ruby`, offering specialized runtime utilities like fetchers for various subscription backends (e.g., Ably, Pusher) and tooling for persisted queries, which are optimized for the Ruby GraphQL ecosystem. This makes it a primary choice for JavaScript frontends interfacing with Ruby-based GraphQL APIs, particularly within Rails applications.
npm install graphql-ruby-clientVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up Apollo Client with `graphql-ruby-client`'s `createFetcher` and execute a mock generated GraphQL query against a GraphQL Ruby server. It shows basic client instantiation and a query execution pattern.
Review the LGPLv3 license terms carefully. If commercial use requires a different license, consider purchasing `graphql-pro` or exploring alternative GraphQL client solutions with more permissive licenses like MIT or Apache 2.0.
If using custom `FieldExtension` on your `graphql-ruby` server, update `after_resolve` implementations to correctly handle the new parameter signature. Verify that any client-side code relying on the behavior of these extensions continues to function as expected after a server upgrade.
Ensure your backend is `graphql-ruby` for full compatibility. If using another GraphQL server, evaluate if a more generic client (e.g., pure Apollo Client) better suits your needs or if the specialized features of `graphql-ruby-client` can still be leveraged effectively.
Integrate the code generation step into your build process. Define your GraphQL operations in `.graphql` files and use the `graphql-ruby-client`'s generator to create the corresponding JavaScript/TypeScript modules before attempting to import and use them in your frontend application.
Run `npm install graphql-ruby-client` or `yarn add graphql-ruby-client` to install the package. Verify the import path is correct.
Ensure you are using `import { createFetcher } from 'graphql-ruby-client';` for named exports, or `import createAblyFetcher from 'graphql-ruby-client/subscriptions/createAblyFetcher';` for default exports from subpaths, and that your environment supports ESM.Ensure your root React component (or equivalent in other frameworks) is wrapped with `<ApolloProvider client={yourApolloClientInstance}>` and that `yourApolloClientInstance` is correctly initialized with the `graphql-ruby-client` fetcher.