LoginSignup
0
0

More than 3 years have passed since last update.

movie graphql

Posted at

graphql을 연습해보았다.

db.js
export const people  =  [
    {   id : "1",
        name : "sean",
        age : 49,
        gender : "female"
    },
    {   id : "2",
        name : "yumi",
        age : 49,
        gender : "female"
    },
    {   id : "3",
        name : "sohui",
        age : 49,
        gender : "female"
    } 
];

export const getById = id => {
    const filteredPeople = people.filter(person => person.id === String(id));
    return filteredPeople[0]
}

resolvers.js
import {people, getById} from "./db";

const resolvers  = {
    Query : {
        people : () => people,
        // person : (_,{id}) => getById(id)
        person : (_,args) => console.log(args)
    }
}

export default resolvers;
schema.graphql
type person {
    id : Int!,
    name : String!,
    age : Int!,
    gender : String!
}

type Query {
    people : [person]!
    person(id:Int!):person!
}
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0