Craft GraphQL APIs in Elixir with Absinthe

Part I — Build a GraphQL API

Chapter 1: Meet GraphQL

When using a REST API, here are some questions we should probably ask ourselves:

Chapter 2: Building a Schema

for menu_item <- PlateSlate.Repo.all(PlateSlate.Menu.Item) do   Map.get(menu_item, :name)
end
@desc "The list of available items on the menu" field :menu_items, list_of(:menu_item) do

«Menu item field definition»

end

Chapter 3: Taking User Input

arg :<some-key>, :string
query ($term: String) { 
  menuItems(matching: $term) {
    name 
  }
}

Chapter 4: Adding Flexibility

Chapter 5: Making a Change with Mutations

mutation do  
  field :create_menu_item, :menu_item do
    arg :input, non_null(:menu_item_input) 
    resolve &Resolvers.Menu.create_item/3
  end
end

Chapter 6: Going Live with Subscriptions

Part II: Publish Your API

Chapter 7: Resolution Middleware

Chapter 8: Securing with Authentication and Authorization

Chapter 9: Tuning Resolution

Part III: Use Your API

Chapter 10: Driving Phoenix Actions with GraphQL

import_types Absinthe.Phoenix.Types

# in the controller
@graphql """
  query Index @action(mode: INTERNAL) {
    menu_items
  }
"""

Chapter 11: Integrating with the Frontend