Обновление данных JSON в столбце graphql

#react-native #graphql #apollo

Вопрос:

У меня есть 2 столбца в моей таблице GraphQL: идентификатор пользователя и данные рецепта, которые содержат коллекцию рецептов. Вот как выглядят данные:

   "data": {  "recipes": [  {  "recipe_data": {  "all_recipes": [  {  "id": 2,  "time": 50,  "image": "https://imagesvc.meredithcorp.io/v3/mm/image?url=https://images.media-allrecipes.com/userphotos/735763.jpg",  "title": "Spicy Chicken and Sweet Potato Stew",  "yield": "6 serving(s)",  "ingredients": [  "1 teaspoon olive oil",  "1 onion, chopped",  "4 cloves garlic, minced",  "1 pound sweet potato, peeled and cubed",  "1 orange bell pepper, seeded and cubed",  "1 pound cooked chicken breast, cubed",  "1 (28 ounce) can diced tomatoes",  "2 cups water",  "1 teaspoon salt",  "2 tablespoons chili powder",  "1 teaspoon ground cumin",  "1 teaspoon dried oregano",  "1 teaspoon cocoa powder",  "¼ teaspoon ground cinnamon",  "¼ teaspoon red pepper flakes",  "1 ½ tablespoons all-purpose flour",  "2 tablespoons water",  "1 cup frozen corn",  "1 (16 ounce) can kidney beans, rinsed and drained",  "½ cup chopped fresh cilantro"  ],  "instructions": "Heat olive oil in a large pot over medium heat. Stir in onion and garlic; cook and stir until the onion has softened and turned translucent, about 5 minutes. Stir in sweet potato, bell pepper, chicken, tomatoes, and 2 cups of water. Season with salt, chili powder, cumin, oregano, cocoa powder, cinnamon, and red pepper flakes. Increase heat to medium-high and bring to a boil. Dissolve flour in 2 tablespoons water, and stir in to boiling stew. Reduce heat to medium-low, cover, and simmer until the potatoes are tender but not mushy, 10 to 20 minutes. Stir the stew occasionally to keep it from sticking. Once the potatoes are done, stir in corn and kidney beans. Cook a few minutes until hot, then stir in cilantro before serving."  },  {  "id": 1,  "time": 70,  "image": "https://imagesvc.meredithcorp.io/v3/mm/image?url=https://images.media-allrecipes.com/userphotos/5472096.jpg",  "title": "White Wine Sangria",  "yield": "6 serving(s)",  "ingredients": [  "1 (750 milliliter) bottle white wine",  "½ cup cubed watermelon",  "½ cup cubed honeydew",  "½ cup sliced strawberries",  "½ cup fresh raspberries",  "6 splashes ginger ale, or to taste"  ],  "instructions": "Combine the white wine, watermelon, honeydew, strawberries, and raspberries in a large pitcher. Chill in refrigerator at least 1 hour to allow flavors to combine. Ladle wine and fruit into wine goblets; top each with a splash of ginger ale to serve."  }  ]  },  "user_id": "xxx"  }  ]  } }  

recipe_data содержит данные JSON, которые я пытаюсь запросить/изменить. Я хочу запросить/изменить только определенные части данных JSON или добавить новый рецепт. Как это возможно с аполлоном?

Комментарии:

1. Способ запроса или изменения данных в вашем API GraphQL зависит от реализации или, точнее, схемы вашего API. В идеале вы используете GraphiQL или игровую площадку GraphQL, чтобы проверить, какие мутации доступны. Что вы используете на стороне сервера?