No release in over a year
Plucks GraphQL document from Ruby codes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 2.0
~> 3.3
~> 0.1.0
 Project Readme

GraphqlTagPluck

Gem Version

A gem for plucking GraphQL queries / mutations / fragments defined by heredocs inside .rb files and exporting them into a json file.

Install this gem and run the following rake task to get the exported json file containing the list of GraphQL queries / mutations / fragments.

bundle exec rake graphql_tag_pluck:generate_graphql_operation_list

Usage

With a sample heredoc like the following inside a .rb file:

SAMPLE_QUERY = <<-GRAPHQL
  query SampleQuery {
    hoge
    fuga {
      piyo
    }
  }
GRAPHQL

will output json file like: (following json content is formatted)

{
  "SampleQuery": {
    "name": "SampleQuery",
    "source": "query SampleQuery {\n  hoge\n  fuga {\n    piyo\n  }\n}",
    "type": "query"
  }
}

by executing

bundle exec rake graphql_tag_pluck:generate_graphql_operation_list

Configuration

You can configure the following options by creating .graphqltagpluckconfig.yaml and specifying them inside.

  • graphql_heredoc_identifiers
    • An array of heredoc identifiers used to define GraphQL queries / mutations / fragments
    • default: ["GRAPHQL", "GQL"]
  • file_glob_pattern
    • A glob pattern to search for the heredocs containing GraphQL queries / mutations / fragments
    • default: "#{Dir.pwd}/**/*.rb"
  • output_path
    • The destination of exported json file path
    • default: "__generated__/graphql_operation_list.json"

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add graphql_tag_pluck

License

The gem is available as open source under the terms of the MIT License.