[Kiwi-ํ•™๊ณผ์ปค๋ฎค๋‹ˆํ‹ฐ] ํšŒ์›ํƒˆํ‡ด API ๊ตฌํ˜„

๐Ÿ–ฅ Project/Kiwi

schema.js

 updateUserStatus(status: Int!): Boolean

 

index.js

updateUserStatus: require('./user/updateUserStatus'),

 

resolvers/user/updateUserStatus.js

const models = require('../../../models');
const { ConflictError } = require('../../errors/errors');
const { setCachedUserUpdated } = require('../../../api/caching');

module.exports = async ({ status }, { id }) => {
    return await models.user
        .update(
            {
                status,
            },
            { where: { id } },
        )
        .then(async () => {
            await setCachedUserUpdated(id);
            return true;
        })
        .catch(() => {
            throw ConflictError('Delete(Update) error occured');
        });
};

 

ํ•œ๋งˆ๋””

3์›”์— ์‹œ์ž‘ํ•œ Kiwi ํ”„๋กœ์ ํŠธ๊ฐ€ 4์›”์ด ๋˜๊ธฐ๋„ ์ „์— ์–ด๋Š์ •๋„ ๋งˆ๋ฌด๋ฆฌ๊ฐ€ ๋˜์—ˆ์—ˆ๋‹ค. ์กธ์—…์ž‘ํ’ˆ ์ œ์ถœ์„ ํ•œ๋‹ฌ ์•ž๋‘๊ณ  ๋‚จ๊ฒจ๋†จ๋˜ ๊ธฐ๋Šฅ๋“ค์„ ์–ด์ œ ๋ง‰ ์ถ”๊ฐ€ํ–ˆ๋‹ค.

ํšŒ์›ํƒˆํ‡ด API๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์‚ญ์ œ์‹œํ‚ค๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์œ ์ €์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋‚จ๊ฒจ๋†“๊ธฐ ์œ„ํ•ด status๋ฅผ ๋ณ€๊ฒฝํ•˜๋„๋ก ๋งŒ๋“ค์—ˆ๋‹ค.

์–ด๋ ต์ง€ ์•Š๊ฒŒ ํšŒ์›ํƒˆํ‡ด API ๊ตฌํ˜„์„ ๋งˆ๋ฌด๋ฆฌํ–ˆ๋‹ค.๐Ÿ˜€๐Ÿ˜€๐Ÿ˜€