Skip to content

tgxworld/discourse-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DiscourseGraphQL

Unofficial Discourse GraphQL API.

Installation

Follow Install a Plugin how-to from the official Discourse Meta, using git clone https://github.com/tgxworld/discourse-graphql.git as the plugin command.

Usage

require "graphql/client"
require "graphql/client/http"

module DiscourseAPI
  HTTP = GraphQL::Client::HTTP.new("http://localhost:3000/discourse-graphql/graphql") do
    def headers(context)
      { "Api-Key": 'ef984ff3d0d242998b7df8eaa975229e4ce07c19500b55baa181fc7abd2fd04b', "Api-Username": 'system' }
    end
  end

  Schema = GraphQL::Client.load_schema(HTTP)

  Client = GraphQL::Client.new(schema: Schema, execute: HTTP)
end

Query = DiscourseAPI::Client.parse(<<~QUERY)
query {
  latestTopics {
    fancyTitle
  }
}
QUERY

DiscourseAPI::Client.query(Query).latest_topics.each do |topic|
  puts topic.fancy_title
end

Feedback

If you have issues or suggestions for the plugin, please open an issue.

About

No description, website, or topics provided.

Resources

License

Stars

3 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages