{"id":13879634,"url":"https://github.com/solidusio/solidus_graphql_api","last_synced_at":"2025-09-06T02:47:50.184Z","repository":{"id":34581451,"uuid":"194296191","full_name":"solidusio/solidus_graphql_api","owner":"solidusio","description":"GraphQL comes to Solidus!","archived":false,"fork":false,"pushed_at":"2023-10-30T13:26:09.000Z","size":2128,"stargazers_count":29,"open_issues_count":9,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-11T06:35:04.047Z","etag":null,"topics":["api","ecommerce","graphql","hacktoberfest","solidus","store"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solidusio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"open_collective":"solidus"}},"created_at":"2019-06-28T15:30:39.000Z","updated_at":"2025-01-11T08:50:04.000Z","dependencies_parsed_at":"2024-02-24T19:51:29.213Z","dependency_job_id":"f77883f8-f9e7-4051-86cb-ae57057d60b3","html_url":"https://github.com/solidusio/solidus_graphql_api","commit_stats":null,"previous_names":["solidusio/solidus_graphql_api","solidusio-contrib/solidus_graphql_api"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/solidusio/solidus_graphql_api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidusio%2Fsolidus_graphql_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidusio%2Fsolidus_graphql_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidusio%2Fsolidus_graphql_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidusio%2Fsolidus_graphql_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solidusio","download_url":"https://codeload.github.com/solidusio/solidus_graphql_api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solidusio%2Fsolidus_graphql_api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273850826,"owners_count":25179357,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","ecommerce","graphql","hacktoberfest","solidus","store"],"created_at":"2024-08-06T08:02:27.362Z","updated_at":"2025-09-06T02:47:50.166Z","avatar_url":"https://github.com/solidusio.png","language":"Ruby","readme":"# SolidusGraphqlApi\n\n[![Maintainability](https://api.codeclimate.com/v1/badges/8ea7739ad6726ad8cfa7/maintainability)](https://codeclimate.com/github/solidusio/solidus_graphql_api/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/8ea7739ad6726ad8cfa7/test_coverage)](https://codeclimate.com/github/solidusio/solidus_graphql_api/test_coverage)\n[![CircleCI](https://circleci.com/gh/solidusio/solidus_graphql_api.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_graphql_api)\n[![Gem Version](https://badge.fury.io/rb/solidus_graphql_api.svg)](https://badge.fury.io/rb/solidus_graphql_api)\n\nProvides a [graphql](https://graphql.org/) api for the [Solidus](https://github.com/solidusio/solidus) ecommerce framework.\n\n## Supported Versions\n\n- Solidus 2.11.x\n- Solidus 3.x\n## Installation\n\nAdd solidus_graphql_api to your Gemfile:\n\n```ruby\ngem 'solidus_graphql_api'\n```\n\nBundle your dependencies and run the installation generator:\n\n```shell\nbin/rails generate solidus_graphql_api:install\n```\n\nUnlike the REST API which has a variety of endpoints, the GraphQL API has a\nsingle endpoint accessible under `/graphql`. It will be automatically \ninserted into your `routes.rb` file after running the generator.\n\nFor example in development you can use:\n\n```\nPOST http://localhost:3000/graphql\n```\n\n## Documentation\n\nThe Solidus GraphQL API documentation can be found [here](https://solidusio.github.io/solidus_graphql_api/docs/).\n\n## Customizations\n\nYou can extend the gem functionality through decorators, just like Solidus.\n\nFor example, assuming we are placing our grapqhl decorators in `app/graphql/types`:\n\n### Adding a new field\n\n```ruby\nmodule Graphql\n  module Types\n    module ProductDecorator\n      def self.prepended(base)\n        base.field :test, GraphQL::Types::String, null: true\n      end\n\n      def test\n        'test'\n      end\n\n      SolidusGraphqlApi::Types::Product.prepend self\n    end\n  end\nend\n```\n\nor also, if we want to add the taxon relation to the type product:\n\n```ruby\nmodule Graphql\n  module Types\n    module ProductDecorator\n      def self.prepended(base)\n        base.field :taxons, SolidusGraphqlApi::Types::Taxon.connection_type, null: true\n      end\n\n      def taxons\n        SolidusGraphqlApi::BatchLoader.for(object, :taxons)\n      end\n\n      SolidusGraphqlApi::Types::Product.prepend self\n    end\n  end\nend\n```\n\n### Modifying an existing field\n\nLike for adding a new field, we modify the `name` field in the same way:\n\n```ruby\nmodule Graphql\n  module Types\n    module ProductDecorator\n      def self.prepended(base)\n        base.field :name, GraphQL::Types::String, null: true\n      end\n\n      def name\n        object.concat(' ', 'Graphql')\n      end\n\n      SolidusGraphqlApi::Types::Product.prepend self\n    end\n  end\nend\n```\n\n### Removing a field\n\n```ruby\nmodule Graphql\n  module Types\n    module ProductDecorator\n      def self.prepended(base)\n        base.remove_field :name\n      end\n\n      SolidusGraphqlApi::Types::Product.prepend self\n    end\n  end\nend\n```\n\n### Adding a new Type\n\nLet's say we want the Product type to return its stock_items:\n\nFirst we create a StockItem type:\n\n```ruby\nmodule Graphql\n  module Types\n    class StockItem \u003c SolidusGraphqlApi::Types::Base::RelayNode\n      description 'StockItem.'\n\n      field :count_on_hand, Integer, null: false\n    end\n  end\nend\n```\n\nAnd in the product decorator type:\n\n```ruby\nrequire_relative 'stock_item'\n\nmodule Graphql\n  module Types\n    module ProductDecorator\n      def self.prepended(base)\n        base.field :stock_items, Graphql::Types::StockItem.connection_type, null: false\n      end\n\n      def stock_items\n        object.stock_items\n      end\n\n      SolidusGraphqlApi::Types::Product.prepend self\n    end\n  end\nend\n```\n\nThe query may look something like:\n\n```ruby\nquery productBySlug ($slug: String!) {\n  productBySlug (slug: $slug) {\n    stockItems {\n      nodes {\n        countOnHand\n      }\n    }\n  }\n}\n```\n\n### Adding a new Query\n\n```ruby\nmodule Graphql\n  module Types\n    module QueryDecorator\n      def self.prepended(base)\n        base.field :taxons, SolidusGraphqlApi::Types::Taxon.connection_type, null: false\n      end\n\n      def taxons\n        Spree::Taxon.all\n      end\n\n      SolidusGraphqlApi::Types::Query.prepend self\n    end\n  end\nend\n```\n\nIn your application you probably want to create a query object to retrieves the taxons.\nCheck `SolidusGraphqlApi::Types::Query` for examples.\n\n## Development\n\n### Testing the extension\n\nFirst bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy\napp if it does not exist, then it will run specs. The dummy app can be regenerated by using\n`bin/rake extension:test_app`.\n\n```shell\nbundle\nbin/rake\n```\n\nTo run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run\n\n```shell\nbundle exec rubocop\n```\n\nWhen testing your application's integration with this extension you may use its factories.\nSimply add this require statement to your spec_helper:\n\n```ruby\nrequire 'solidus_graphql_api/factories'\n```\n\n## Running the sandbox\n\nTo run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for\nthe sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to\n`sandbox/bin/rails`.\n\nHere's an example:\n\n```shell\n$ bin/rails server\n=\u003e Booting Puma\n=\u003e Rails 6.0.2.1 application starting in development\n* Listening on tcp://127.0.0.1:3000\nUse Ctrl-C to stop\n```\n\n### Updating the changelog\n\nBefore and after releases the changelog should be updated to reflect the up-to-date status of\nthe project:\n\n```shell\nbin/rake changelog\ngit add CHANGELOG.md\ngit commit -m \"Update the changelog\"\n```\n\n### Releasing new versions\n\nPlease refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.\n\n## License\n\nCopyright (c) 2020-2021 Nebulab, released under the New BSD License.\n","funding_links":["https://opencollective.com/solidus"],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidusio%2Fsolidus_graphql_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolidusio%2Fsolidus_graphql_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolidusio%2Fsolidus_graphql_api/lists"}