Skip to content

feat: add GraphQL endpoint support#124

Merged
andrii-bodnar merged 4 commits into
crowdin:mainfrom
GHX5T-SOL:fix-100-graphql-support
May 20, 2026
Merged

feat: add GraphQL endpoint support#124
andrii-bodnar merged 4 commits into
crowdin:mainfrom
GHX5T-SOL:fix-100-graphql-support

Conversation

@GHX5T-SOL
Copy link
Copy Markdown
Contributor

Summary

  • Add Crowdin::Client#graphql for GraphQL POST requests to /api/graphql.
  • Support Enterprise base URLs and a custom endpoint URL for tests/local GraphQL servers.
  • Add unit coverage for default, Enterprise, and custom URL behavior, plus README usage.

Fixes #100.

Validation

  • ruby -c lib/crowdin-api/client/client.rb -> Syntax OK
  • ruby -c spec/unit/client_spec.rb -> Syntax OK
  • git diff --check -> passed
  • git diff --cached --check -> passed
  • git diff origin/main..HEAD --check -> passed
  • git diff | gitleaks stdin --no-banner --redact --timeout 30 -> no leaks found
  • git show --format= --patch HEAD | gitleaks stdin --no-banner --redact --timeout 30 -> no leaks found
  • Standalone Ruby smoke with RestClient::Request.execute stub verified default, Enterprise, custom URL, payload, and parsed response behavior -> standalone graphql smoke passed

Not run:

  • bundle exec rspec spec/unit/client_spec.rb could not complete in this local macOS 12 environment. System Ruby bundle install fails building unf_ext because the CLT SDK has universal-darwin22 Ruby headers while Ruby 2.6 Makefiles expect universal-darwin21; Homebrew portable Ruby 4.0.4 installs the bundle but hangs loading the bundled native json extension; brew install ruby and brew install ruby@3.4 both attempted long LLVM/Rust source builds and were aborted.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class GraphQL support to the Crowdin Ruby API client by introducing a Crowdin::Client#graphql helper that POSTs to /api/graphql, with coverage for default, Enterprise, and custom endpoint URL behaviors.

Changes:

  • Added Crowdin::Client#graphql to send GraphQL POST requests to /api/graphql (or a custom URL).
  • Added unit specs covering default, Enterprise, and custom GraphQL endpoint URL behavior.
  • Documented basic GraphQL usage in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/crowdin-api/client/client.rb Adds the #graphql method that performs a JSON POST to the GraphQL endpoint.
spec/unit/client_spec.rb Adds unit tests verifying URL selection (default/Enterprise/custom) and response parsing.
README.md Adds a “GraphQL API” section with example usage and custom endpoint URL support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/crowdin-api/client/client.rb Outdated
Comment thread lib/crowdin-api/client/client.rb Outdated
Comment thread README.md Outdated
@GHX5T-SOL
Copy link
Copy Markdown
Contributor Author

Pushed 8f5d8d5 to address the RuboCop Metrics/ClassLength failure by moving the GraphQL helper into an included Crowdin::Web::GraphqlExtensions module while keeping Crowdin::Client#graphql unchanged.

Validation:

  • ruby -c lib/crowdin-api.rb
  • ruby -c lib/crowdin-api/client/client.rb
  • ruby -c lib/crowdin-api/core/graphql_extensions.rb
  • git diff --cached --check
  • gitleaks protect --staged --redact --no-banner --timeout 30
  • git diff ghx5t/fix-100-graphql-support..HEAD --check
  • git show --format= --patch HEAD | gitleaks stdin --no-banner --redact --timeout 30

Local bundle exec rubocop / bundle exec rspec could not run on this Mac because Bundler cannot build native gems with the system Ruby headers. The new Test and Lint workflow run is currently action_required with no jobs, so it needs maintainer approval before CI can confirm the fix.

@GHX5T-SOL
Copy link
Copy Markdown
Contributor Author

Pushed 3b31806 with the CI follow-up.

What changed:

  • fixed the RuboCop Metrics/ClassLength failure by keeping the extension includes on one line
  • changed the custom GraphQL endpoint option to a keyword argument (url:), so the method signature matches the supported option
  • updated the README wording so it does not imply GraphQL is Enterprise-only

Validation I could run locally:

  • ruby -c lib/crowdin-api/client/client.rb
  • ruby -c lib/crowdin-api/core/graphql_extensions.rb
  • ruby -c spec/unit/client_spec.rb
  • git diff --cached --check
  • gitleaks git --no-banner --redact --staged --exit-code 1

I could not run the full local bundle exec rubocop / bundle exec rake suite on this Mac because the bundle gems are not installed in the system Ruby environment; after installing Bundler 2.4.22 locally, Bundler still reports missing project gems/native setup. The pushed change is meant to let the GitHub Actions matrix verify the full suite.

@GHX5T-SOL GHX5T-SOL force-pushed the fix-100-graphql-support branch from 3b31806 to 577ac15 Compare May 20, 2026 08:07
@GHX5T-SOL
Copy link
Copy Markdown
Contributor Author

Follow-up after the first 3b31806 CI run: RuboCop correctly rejected the grouped include statement via Style/MixinGrouping, so I replaced that with 577ac15.

The includes are back in separate statements, and the class-length reduction now comes from grouping the existing client readers into one attr_reader line instead. I reran:

  • ruby -c lib/crowdin-api/client/client.rb
  • git diff --check
  • git diff --cached --check
  • gitleaks git --no-banner --redact --staged --exit-code 1

Full bundle exec rubocop / bundle exec rake remains blocked locally by the missing bundle/native Ruby setup noted above, so I am leaving the matrix to verify the final lint/test result.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.39%. Comparing base (1f8da2c) to head (2074182).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #124      +/-   ##
==========================================
+ Coverage   98.38%   98.39%   +0.02%     
==========================================
  Files          63       64       +1     
  Lines        3130     3156      +26     
==========================================
+ Hits         3079     3105      +26     
  Misses         51       51              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread lib/crowdin-api/core/graphql_extensions.rb Outdated
@GHX5T-SOL
Copy link
Copy Markdown
Contributor Author

Thanks, this was a good catch. I pushed 2074182 to execute the GraphQL request with a response block so non-2xx responses can still be parsed, and added a unit spec for a parsed 400 GraphQL error body.

Validated with:

  • ruby -c lib/crowdin-api/core/graphql_extensions.rb && ruby -c spec/unit/client_spec.rb
  • bundle exec rspec spec/unit/client_spec.rb --format progress
  • bundle exec rubocop lib/crowdin-api/core/graphql_extensions.rb spec/unit/client_spec.rb
  • git diff --check
  • git diff | gitleaks stdin --no-banner --redact --exit-code 1

@andrii-bodnar andrii-bodnar merged commit 984288e into crowdin:main May 20, 2026
7 checks passed
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.

Add the GraphQL endpoint support

3 participants