[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 ๊ตฌํ์ ๋ง๋ฌด๋ฆฌํ๋ค.๐๐๐
'๐ฅ Project > Kiwi' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Kiwi-ํ๊ณผ์ปค๋ฎค๋ํฐ] ํ์ ํ๊ณผ๋ณ๊ฒฝ API ๊ตฌํ (0) | 2021.05.20 |
---|