Skip to content

Instantly share code, notes, and snippets.

@ShopifyEng
Created July 2, 2021 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShopifyEng/1f92cee91f2932a0ef665594418764d3 to your computer and use it in GitHub Desktop.
Save ShopifyEng/1f92cee91f2932a0ef665594418764d3 to your computer and use it in GitHub Desktop.
Understanding GraphQL for Beginners–Part Two - Try it yourself #2
query {
findFood(term: "China") {
id
name
nutrition {
calories
}
}
}
{
"data": {
"findFood": [
{
"id": "2",
"name": "Beef Chow Mein",
"nutrition": {
"calories": "459"
}
}
]
}
}
field :find_food, [Types::FoodType], null: false do
description 'Get all food items based on place of origin.'
argument :term, String, required: true
end
def find_food(term:)
Food.where('place_of_origin = ?', term)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment