Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Implements the initial GraphQL server in Ruby #39

Merged
merged 18 commits into from
Oct 18, 2018

Conversation

hpjaj
Copy link
Contributor

@hpjaj hpjaj commented Oct 14, 2018

Background

Once we have started saving all of the GitHub and JIRA data in our database, we will want to offer up that data to our FE through a GraphQL server.

The primary resource for this server implementation was GraphQL Ruby.

Associated Issue

#15

Definition of Done

  • Create an extensible, organized, encapsulated query & mutation file structure
  • Basic type classes created for these models:
    • GithubUser
    • Organization
    • Repository
    • Statistic
    • User
  • Basic queries created for these models:
    • GithubUser
    • Organization
    • Repository
    • Statistic
    • User
  • create mutation for Statistic
  • update mutation for Statistic
  • Yard docs
  • Spec coverage
  • RuboCop adjustments

hpjaj added 12 commits October 13, 2018 15:41
Install the current recommended default files and structure through this command:

rails generate graphql:install

See:

http://graphql-ruby.org/schema/generators#graphqlinstall
Note that I started creating a sub directory for query types.  This is so that we don’t have all of the queries, for all of the models, all inside of one large file.

This encapsulate’s each model’s query logic inside of its own file, and then includes it in the main “app/graphql/types/query_type.rb” file.

This file is the one that is wired up to the schema, through the query root entry point.

I derived this implementation pattern from the HasRecommendedItems section of:

http://graphql-ruby.org/fields/resolvers.html
Now queries can be organized by the model (or any common theme) in which they fall under.  And each query resides in its own file.

The queries for a given model (or theme) role up into a manifest of queries.  This identifies all of the queries currently available for the given model (or theme).

Each model’s manifest role’s up into the root query, that is passed to the schema.  Which is the expectation and pattern set by GraphQL and the GraphQL gem.
This commit:

- implements the create and update mutations for Statistic
- sets the basic pattern for mutations, re: file/code organization
- uses an Input Object for the mutations

see: http://graphql-ruby.org/mutations/mutation_classes.html

see: http://graphql-ruby.org/type_definitions/input_objects.html#customizing-input-objects
@hpjaj hpjaj added backend WIP Work-in-progress labels Oct 14, 2018
@hpjaj hpjaj force-pushed the 15-graphql-ruby-server branch 2 times, most recently from 2ce5b90 to 5d181bf Compare October 16, 2018 22:47
@hpjaj hpjaj force-pushed the 15-graphql-ruby-server branch from 5d181bf to 377b553 Compare October 16, 2018 22:48
@hpjaj hpjaj removed the WIP Work-in-progress label Oct 17, 2018
@hpjaj hpjaj requested review from kfrz, RobAWilkinson and dhall October 17, 2018 14:47
@hpjaj hpjaj force-pushed the 15-graphql-ruby-server branch from 992b0ee to 2eb452a Compare October 17, 2018 14:56
* adds a small task and test to update schema

* adds graphql schema

* tabs

* formatting
@RobAWilkinson RobAWilkinson merged commit 16debe4 into master Oct 18, 2018
@hpjaj hpjaj deleted the 15-graphql-ruby-server branch December 16, 2018 20:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants