Skip to content

Instantly share code, notes, and snippets.

View thoth-ky's full-sized avatar
👨‍💻
Code.Eat.Watch

Mutuku Kyalo thoth-ky

👨‍💻
Code.Eat.Watch
View GitHub Profile
@thoth-ky
thoth-ky / create_book.rb
Created February 23, 2019 10:51
Example Graphql Mutations
# app/graphql/mutations/create_book.rb
module Mutations
class CreateBook < GraphQL::Schema::RelayClassicMutation
# define return fields (once book is created what can be returned)
field :book, Types::BookType, null: false
# define arguments required to create a book
# you can define a a new Type for inputs so you replace thr following
# lines by something like this:
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())