Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const schemaExtensionResolvers = {
- user: {
- city_weather: async (parent, args, context, info) => {
- const cityDetails = await getWoeid(parent.city);
- if (!cityDetails) {
- return null;
- }
- const weather = await getWeather(cityDetails);
- if (!weather) {
- return null;
- }
- let consolidated_weather = weather.consolidated_weather;
- // check for args applicable_date to apply filter
- consolidated_weather = args.applicable_date ? consolidated_weather.find(item => item.applicable_date === args.applicable_date) : consolidated_weather[0];
- const respObj = {'temp': consolidated_weather.the_temp.toString(), 'min_temp': consolidated_weather.min_temp.toString(), 'max_temp': consolidated_weather.max_temp.toString(), 'city_name': weather.title, 'applicable_date': consolidated_weather.applicable_date};
- return respObj;
- }
- }
- };
Add Comment
Please, Sign In to add comment