# Unofficial Discourse GraphQL API Plugin

**URL:** https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955
**Category:** Plugin
**Created:** [July 27, 2020, 2:34pm UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955 "2020-07-27T14:34:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [July 27, 2020, 2:34pm UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/1 "2020-07-27T14:34:23Z")

</div>

# discourse-graphql - [GitHub - tgxworld/discourse-graphql · GitHub](https://github.com/tgxworld/discourse-graphql)

Hi all, I’ll like to share the [discourse-graphql](https://github.com/tgxworld/discourse-graphql) plugin which I’ve been working on recently as a personal project. The plugin is still a work in progress as there are only 3 query fields being exposed. Since I personally don’t use the Discourse API for integration, I’ll like to hear from potential users what queries or mutations you’ll like to see added to the plugin. Simply provide me with your use case and what fields you’re looking for in this topic so that I can add it to the plugin.

---

<div class="post-metadata">

### Author: ![4ong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/4ong/32/186618_2.png) [@4ong](https://meta.discourse.org/u/4ong)
#### Post date: [August 4, 2020, 11:27am UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/2 "2020-08-04T11:27:20Z")

</div>

Hi @tgxworld, very interesting stuff.  
As you already working in this direction - what do you think about   
 [GitHub - dosco/graphjin: GraphJin - An Automagical Compiler to Connect AI to Your Databases · GitHub](https://github.com/dosco/super-graph)   
  
[https://www.youtube.com/watch?v=TGq9wJAj78I](https://www.youtube.com/watch?v=TGq9wJAj78I)

Or is it a crazy idea to use it with Discourse?  
AFAIK it works with Rails in nice way, including Rails authentication supported (Redis, Memcache, Cookie). And it can be integrated in existing Rails apps, but I’m not sure if it is realistic to use it within a plugin.

What do you think?

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [August 5, 2020, 1:40am UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/3 "2020-08-05T01:40:50Z")

</div>

Hi @4ong 👋

Super Graph looks interesting but I’m not sure if it’ll fit our needs here. The main problem I see is that the SQL queries that we need to generate is not straight forward and can involve many conditional paths. Those conditions are probably not easy to express with just a GraphQL query.

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [August 5, 2020, 2:42am UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/4 "2020-08-05T02:42:39Z")

</div>

> [@tgxworld](#):
>
> Hi all, I’ll like to share the [discourse-graphql](https://github.com/tgxworld/discourse-graphql) plugin which I’ve been working on recently as a personal project.

Dear Alex,

Thank you for sharing this plugin. I learned a lot from reading your plugin code and how you approached this.

**Bookmarked!**

Thanks again.

---

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [December 14, 2020, 3:12am UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/5 "2020-12-14T03:12:05Z")

</div>

Thank you, I think this plugin will be a great help for some custom GraphQL endpoints I need in my Discourse instance.

However, Discourse responds with 502 Bad Gateway after rebuilding.

Here are the logs.

> **Logs**
>
> ```plaintext
> /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader/callbacks.rb:18:in `on_file_autoloaded': expected file /var/www/discourse/plugins/discourse-graphql/app/graphql/loaders/record_loader.rb to define constant Loaders::RecordLoader, but didn't (Zeitwerk::NameError)
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:27:in `block in require'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `tap'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:53:in `require_relative'
> from /var/www/discourse/plugins/discourse-graphql/app/graphql/discourse_schema.rb:3:in `<main>'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:409:in `const_get'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:409:in `block (2 levels) in eager_load'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:733:in `block in ls'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:725:in `foreach'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:725:in `ls'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:404:in `block in eager_load'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:393:in `synchronize'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:393:in `eager_load'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:508:in `each'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader.rb:508:in `eager_load_all'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application/finisher.rb:122:in `block in <module:Finisher>'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `instance_exec'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:32:in `run'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:61:in `block in run_initializers'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:228:in `block in tsort_each'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:431:in `each_strongly_connected_component_from'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:349:in `block in each_strongly_connected_component'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `call'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:347:in `each_strongly_connected_component'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:226:in `tsort_each'
> from /usr/local/lib/ruby/2.7.0/tsort.rb:205:in `tsort_each'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/initializable.rb:60:in `run_initializers'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/application.rb:363:in `initialize!'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/railtie.rb:190:in `public_send'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.3/lib/rails/railtie.rb:190:in `method_missing'
> from /var/www/discourse/config/environment.rb:7:in `<top (required)>'
> from config.ru:7:in `require'
> from config.ru:7:in `block in <main>'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `instance_eval'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `initialize'
> from config.ru:1:in `new'
> from config.ru:1:in `<main>'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/unicorn-5.7.0/lib/unicorn.rb:54:in `eval'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/unicorn-5.7.0/lib/unicorn.rb:54:in `block in builder'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:822:in `build_app!'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:141:in `start'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/gems/unicorn-5.7.0/bin/unicorn:128:in `<top (required)>'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/bin/unicorn:23:in `load'
> from /var/www/discourse/vendor/bundle/ruby/2.7.0/bin/unicorn:23:in `<main>'
> 
> ```

I don’t know what that means, there’s a [SO answer](https://stackoverflow.com/a/60880320/116206) with a similar error message but I’m not certain it fits here.

Do you have any idea?

**EDIT** : I’ve sent a [PR](https://github.com/tgxworld/discourse-graphql/pull/1) fixing this issue.

Thanks.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 30, 2021, 1:34am UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/6 "2021-06-30T01:34:09Z")

</div>

Sorry going to close this topic off. I’ve not had time to get the plugin to a good state and we don’t really have any real need for this at Discourse.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [June 30, 2021, 1:34am UTC](https://meta.discourse.org/t/unofficial-discourse-graphql-api-plugin/158955/7 "2021-06-30T01:34:11Z")

</div>


