Skip to content

Commit

Permalink
Queries: query links using graphiql
Browse files Browse the repository at this point in the history
  • Loading branch information
ztratify committed Nov 30, 2020
1 parent c6e84df commit 27fddbb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
7 changes: 7 additions & 0 deletions app/graphql/types/link_type.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Types
class LinkType < Types::BaseObject
field :id, ID, null: false
field :url, String, null: false
field :description, String, null: false
end
end
15 changes: 7 additions & 8 deletions app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
module Types
class QueryType < Types::BaseObject
# Add root-level fields here.
# They will be entry points for queries on your schema.
class QueryType < BaseObject
# queries are just represented as fields
# `all_links` is automatically camelcased to `allLinks`
field :all_links, [LinkType], null: false

# TODO: remove me
field :test_field, String, null: false,
description: "An example field added by the generator"
def test_field
"Hello World!"
# this method is invoked, when `all_link` fields is being resolved
def all_links
Link.all
end
end
end

0 comments on commit 27fddbb

Please sign in to comment.