Last active
November 10, 2019 09:50
-
-
Save harigopal/d6a8c4e27e1df99c7ef84db39b9b5e5e to your computer and use it in GitHub Desktop.
Conventions for setting up a GraphQL Server on Rails - Schema & QueryType
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/graphql/my_rails_app_schema.rb | |
class MyRailsAppSchema < GraphQL::Schema | |
mutation(Types::MutationType) | |
query(Types::QueryType) | |
end | |
# app/graphql/types/query_type.rb | |
module Types | |
class QueryType < Types::BaseObject | |
# Add root-level fields here. They will be entry points for queries on your schema. | |
field :test_field, String, null: false, description: "An example field added by the generator" | |
# A method with the same name as the field will be called when that field is asked for in a query. | |
def test_field | |
"Hello World!" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment