16. SeePhoto

김종민·2022년 4월 25일
0

insta-backend

목록 보기
15/37

1. seePhoto.typeDefs.js

import { gql } from 'apollo-server'

export default gql`
  type Query {
    seePhoto(id: Int!): Photo
  }
`

사진 id입력하면 사진을 return함.

2. seePhoto.resolvers.js

import prisma from '../../client'

export default {
  Query: {
    seePhoto: (_, { id }) =>
      prisma.photo.findUnique({
        where: { id },
      }),
  },
}

check!!
Query는 async, await 가 사용되지 않음.
사진 1장 찾는 것.

profile
코딩하는초딩쌤

0개의 댓글