Ruby support for GraphQL API calls to MOE's Student Learning Space. This includes a few functionalities:
- Token management
- GraphQL Templates
Requires Ruby 2.4+.
Add this line to your application's Gemfile:
gem 'sls_adf'Configure the gem in the following manner:
(This can be placed in config/initializers/ for Rails applications)
SlsAdf.configure do |c|
c.graphql_url = 'https://example.com'
c.get_token_url = 'https://example.com/token'
c.client_id = 'Foo'
c.client_secret = 'Bar'
endAnd then execute:
$ bundle
sls_adf provides ruby methods which can be used to make GraphQL calls to SLS ADF.
To use, follow the installation instructions above and configure the necessary details.
# Queries
response = SlsAdf::Query.user('id')
response = SlsAdf::Query.context('uuid')
response = SlsAdf::Query.subject_group('uuid')
response = SlsAdf::Query.assignment('uuid')
response = SlsAdf::Query.task('uuid')
# Mutations
response = SlsAdf::Mutation.create_assignment(assignment_input)
response = SlsAdf::Mutation.update_assignment(uuid, assignment_input)
response = SlsAdf::Mutation.delete_assignment(uuid)
response = SlsAdf::Mutation.update_task(uuid, task_input)
response = SlsAdf::Mutation.create_notification(notification_input)sls_adf uses Github's graphql-client for
graphql functionality, and Typhoeus to make
http calls.
Two classes, Adapter (SlsAdf::Util::Adapter) and Token (SlsAdf::Util::Token) are
defined in this gem to support the most naive use case. These classes are designed to be
extended or replaced to support different use cases.
sls_adf provides pre-defined GraphQL calls to ADF. Should you require other calls,
you may:
- Declare your custom GraphQL queries or mutations using the
graphql-client DSL,
then execute them using
SlsAdf.querywith the appropriate variables. - For easy reuse, create a new class that inherits from
SlsAdf::Baseto wrap your custom queries, mutations or fragments.
Key Commands:
bin/setup: Install dependencies and copy.envfile.bin/console: Run an interactive prompt (requires configuration on .envfile).rake specorbundle exec rspec: Run tests.rake sls_adf:update_schema: Update the SLS ADF GraphQL schema (requires configuration on .envfile).
Bug reports and pull requests are welcome on GitHub.
The gem is available as open source under the terms of the MIT License.