Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { ApolloServer, gql } = require('apollo-server');
- const BoredAPI = require(".//datasource");
- const typeDefs = gql`
- type Event {
- activity: String!
- accessibility: Float!
- type: String!
- participants: Int!
- price: Float!
- key: Int!
- }
- type Query {
- event(price: Float!): Event;
- events: [Event];
- }`
- const resolvers = {
- Query: {
- event: async (_source, { price }, { dataSources }) => {
- return dataSources.BoredAPI.getEventP(price);
- }
- }
- };
- const server = new ApolloServer({
- typeDefs,
- resolvers,
- dataSources: () => {
- return {
- BoredAPI: new BoredAPI(),
- };
- },
- });
- server.listen().then(({ url }) => {
- console.log(`🚀 Server ready at ${url}`);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement