launchpad가 망할 것을 대비하여 전체 소스를 댓글로 첨부한다.
import { makeExecutableSchema } from 'graphql-tools';
const ballMaxCount = 5;
let ballCount = ballMaxCount;
let scores = [];
const typeDefs = `
type Score {
result: Boolean
}
type Query {
getBallCount: Int
getScores: [ Score ]
}
type Mutation {
submitKick: Query
}
`;
const resolvers = {
Query: {
getBallCount: (root, args, context) => ballCount,
getScores: ()=> scores
},
Mutation: {
submitKick: (root, args, context) => {
if (ballCount === 0) {
ballCount = ballMaxCount;
scores = [];
}
let result = !~~(Math.random()+0.5);
scores.push( { result } );
ballCount--;
return {
result
};
}
}
};
export const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
export function context(headers, secrets) {
return {
headers,
secrets,
};
};
아놔 진짜 launchpad 망했네. 나님 선견지명 무엇?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit