GraphQL Client is a Ruby library for declaring, composing and executing GraphQL queries. Sample configuration for a GraphQL Client to query from the SWAPI GraphQL Wrapper. If you haven't already, familiarize yourself with the GraphQL query syntax. Queries are declared with the same syntax inside of a <<-'GRAPHQL' heredoc. There isn't any special query builder Ruby DSL. This client library encourages all GraphQL queries to be declared statically and assigned to a Ruby constant. If you're using Ruby on Rails ERB templates, theres a ERB extension that allows static queries to be defined in the template itself. In standard Ruby you can simply assign queries and fragments to constants and they'll be available throughout the app. However, the contents of an ERB template is compiled into a Ruby method, and methods can't assign constants. So a new ERB tag was extended to declare static sections that include a GraphQL query.

Features

  • Queries can reference variables that are passed in at query execution time
  • Fragments are declared similarly
  • To include a fragment in a query, reference the fragment by constant
  • This works for namespaced constants
  • Add graphql-client to your Gemfile and then run bundle install
  • Ruby library for declaring, composing and executing GraphQL queries

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

MIT License

Follow graphql-client

graphql-client Web Site

You Might Also Like
Gen AI apps are built with MongoDB Atlas Icon
Gen AI apps are built with MongoDB Atlas

The database for AI-powered applications.

MongoDB Atlas is the developer-friendly database used to build, scale, and run gen AI and LLM-powered apps—without needing a separate vector database. Atlas offers built-in vector search, global availability across 115+ regions, and flexible document modeling. Start building AI apps faster, all in one place.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of graphql-client!

Additional Project Details

Programming Language

Ruby

Related Categories

Ruby Libraries

Registered

2023-03-06