This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ApiBuilder = require('claudia-api-builder'); | |
| const api = new ApiBuilder(); | |
| api.get('/hello', req => { | |
| const randomNumber = Math.floor(Math.random() * 10); | |
| const message = `Hello ${req.queryString.name}. Your lucky number is ${randomNumber}`; | |
| return message; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { gql } = require('apollo-server'); | |
| const typeDefs = gql` | |
| type Orders { | |
| _id: String! | |
| userId: Int! | |
| amount: Int! | |
| tax: Int! | |
| createdAt: String! | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const orders = [ | |
| { | |
| _id: '5d35f11f56104d59a05f21d4', | |
| userId: 1778, | |
| amount: 600, | |
| tax: 60, | |
| createdAt: '1563816223063.0', | |
| }, | |
| { | |
| _id: '5d383702280bb47f048ace35', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const orders = require('../data'); | |
| const resolvers = { | |
| Query: { | |
| orders: (_, args) => { | |
| return orders; | |
| } | |
| }, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { GraphQLScalarType } = require('graphql') ; | |
| const { Kind } = require('graphql/language'); | |
| const orders = require('../db'); | |
| const resolvers = { | |
| Query: { | |
| orders: (_, args) => { | |
| return orders; | |
| } | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { gql } = require('apollo-server'); | |
| const typeDefs = gql` | |
| scalar Date | |
| type Orders { | |
| userId: Int! | |
| amount: Int! | |
| createdAt: Date! | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const orders = [ | |
| { | |
| userId: 1778, | |
| amount: 600, | |
| createdAt: '1563816223063.0', | |
| }, | |
| { | |
| userId: 1781, | |
| amount: 250, | |
| createdAt: '1563965186852.0', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const app = express(); | |
| const port = 3000; | |
| app.use(bodyParser.json()); | |
| app.post('/post', async (req, res) => { | |
| const { title, author } = req.body; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const handleErrors = require('./middleware/handleErrors'); | |
| const { BadRequest } = require('./utils/errors'); | |
| const app = express(); | |
| const port = 3000; | |
| app.use(bodyParser.json()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express'); | |
| const bodyParser = require('body-parser'); | |
| const handleErrors = require('./middleware/handleErrors'); | |
| const { BadRequest } = require('./utils/errors'); | |
| const app = express(); | |
| const port = 3000; | |
| app.use(bodyParser.json()); |