Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

Add GraphiQL and GraphQL Controller#6

Merged
xuorig merged 2 commits intomasterfrom
graphiql
Feb 10, 2017
Merged

Add GraphiQL and GraphQL Controller#6
xuorig merged 2 commits intomasterfrom
graphiql

Conversation

@xuorig
Copy link
Copy Markdown
Collaborator

@xuorig xuorig commented Feb 8, 2017

Adds graphiql at /graphiql and a GraphQL controller with an #execute action at /graphql.

Moved types to models

@cjoudrey

elsif variables.is_a?(String)
JSON.parse(variables)
else
variables
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do anything here? It could be an array, maybe we should Bad Request in that case?

Comment thread app/controllers/graphql_controller.rb Outdated
@@ -0,0 +1,20 @@
class GraphqlController < ApplicationController
def execute
query_string = params[:query]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to .to_s here in case we're passed an array or hash?

if variables.blank?
{}
elsif variables.is_a?(String)
JSON.parse(variables)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had a random thought, this could be an array too.

Copy link
Copy Markdown
Collaborator Author

@xuorig xuorig Feb 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables.is_a?(String) no ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see what you mean

@xuorig xuorig merged commit bb04f4a into master Feb 10, 2017
@xuorig xuorig deleted the graphiql branch February 10, 2017 04:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants