Food Log Entries

The foodLogs query retrieves a comprehensive list of food log entries for the authenticated user within a specified date range. This query allows access to data for all food categories.

Available Arguments

Argument

Type

Required?

Description

Start

Date

True

Starting filter date range, format YYYY-mm-dd

End

Date

True

Ending filter date range, format YYYY-mm-dd

Id

String

False

ID of the logged food. Add this parameter to get the specific information of a logged food.

Available Fields

Field

Type

Note

name

String

Name of the logged item

date

Date

Date of the log entry

mealType

MealType

Type of meal that was logged. RECIPE, MENU_ITEM

servings

Object that contains predefined serving types and sizes

serving

Float

Index of the servings element that was logged

quantity

Float

Quantity of logged servings

servingWeight

Float

Weight in grams of each serving

food

Food

union Food = BrandedFoodNodeProxy, CommonFoodNodeProxy, MealProxy, MyBrandedFoodProxy, MyCommonFoodProxy, RecipeProxy, UserRecipeProxy.

Pagination

The foodLogs query supports the use of pagination. The following fields can be used

cursor
    }
     pageInfo {
      endCursor
      hasNextPage
    }

Refer to the pagination documentation for more information.

Examples

GraphQL Examples

Get the meals logged on specific dates

The following example retrieves the meals logged between to given dates:

{
  foodLogs(start: "2021-09-01", end: "2021-10-05"){
   edges {
      node
         {
        foodId
        portionModifier
        date
        grams
        mealTime
      }
    }
   }
}

curl Example

curl -XPOST 'https://production.suggestic.com/graphql' \
  -H 'Authorization: Bearer <User-JWT>' \
  -H 'Content-Type: application/json' \
--data-raw '{"query": "{foodLogs(start:\"2021-09-01\", end:\"2021-10-05\"){edges{ node { id date mealTime foodId grams servings}} }}"}'

GraphQL Example

query($first: Int, $start: Date! $end: Date!) {
  foodLogs(first: $first, start: $start, end: $end){
     edges {
       cursor 
         node {
            id 
            date 
            mealTime 
            foodId 
            grams 
            servings
            time 
            portionModifier
           }
          }
        pageInfo {
          hasNextPage
         hasPreviousPage 
         startCursor
         endCursor
            }
        }
    }

GraphQL Example with nutrients and all food data types

query($start: Date! $end: Date!) {
  foodLogs(start: $start, end: $end){
     edges {
       cursor 
         node {
            id 
            date 
            mealTime 
            foodId
            grams 
            servings
            time
            portionModifier
            food {
					... on BrandedFoodNodeProxy {
						brandedFood {
							brandName
							brandOwner
							dataType
							description
							foodDataId
							householdServingFulltext
							name
							nutrients {
							  amount
							  name
							  type
							  unit
							}
							servingSize
							servingSizeUnit
						}
					}
					... on CommonFoodNodeProxy {
						commonFood {
							dataType
							description
							foodDataId
							name
							nutrients {
								amount
								name
								type
								unit
							}
							portions {
								amount
								gramWeight
								modifier
								seqNum
							}
						}
					}
					... on MealProxy {
						meal {
							id
							meal
							numOfServings
							recipe {
								id
								databaseId
								name
								numberOfServings
								nutritionalInfo {
									calcium
									calories
									carbs
									cholesterol
									fat
									fiber
									iron
									potassium
									protein
									saturatedFat
									sodium
									sugar
									transFat
									vitaminD
								}
								serving
								servingWeight
							}
						}
					}
					... on MyBrandedFoodProxy {
						myBrandedFood {
							brandName
							brandOwner
							dataType
							description
							foodDataId
							householdServingFulltext
							name
							nutrients {
							  amount
							  name
							  type
							  unit
							}
							servingSize
							servingSizeUnit
						}
					}
					... on RecipeProxy {
						recipe {
							databaseId
							name
							numberOfServings
							nutritionalInfo {
								calcium
								calories
								carbs
								cholesterol
								fat
								fiber
								iron
								potassium
								protein
								saturatedFat
								sodium
								sugar
								transFat
								vitaminD
							}
							serving
							servings {
							  amount
							  description
							  equivalent
							  unit
							}
							servingWeight
						}
					}
					... on UserRecipeProxy {
						userRecipe {
							name
							nutrientsPerServing {
								amount
								name
								type
								unit
							}
							servingWeight
							text
						}
					}
				}
           }
          }
        pageInfo {
          hasNextPage
         hasPreviousPage 
         startCursor
         endCursor
            }
        }
    }

Last updated