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
var MoviesList = [ | |
{ | |
id: 1, | |
title: 'Avengers: Endgame', | |
rate: '8.7', | |
Year: 2019 | |
}, | |
{ | |
id: 2, | |
title: 'John Wick: Chapter 3 - Parabellum', |
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
var express = require('express'); | |
var express_graphql = require('express-graphql'); | |
var { schema, root} = require('./schema'); | |
// Create an express server and a GraphQL endpoint | |
var app = express(); | |
app.use('/graphql', express_graphql({ | |
schema: schema, | |
rootValue: root, | |
graphiql: true |
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
module.exports = { | |
siteMetadata: { | |
title: `Gatsby With Express`, | |
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, | |
author: `@gatsbyjs`, | |
}, | |
plugins: [ | |
`gatsby-plugin-react-helmet`, | |
{ | |
resolve: `gatsby-source-filesystem`, |
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
module.exports = { | |
siteMetadata: { | |
title: `Gatsby With Express`, | |
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`, | |
author: `@gatsbyjs`, | |
}, | |
plugins: [ | |
`gatsby-plugin-react-helmet`, | |
{ | |
resolve: `gatsby-source-filesystem`, |
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
import React from "react" | |
import Layout from "../components/layout" | |
import SEO from "../components/seo" | |
import { useStaticQuery, graphql } from "gatsby" | |
import StarIcon from "../Icons/starIcon" | |
const IndexPage = () => { | |
const { movie } = useStaticQuery( | |
graphql` | |
query MyQuery { |
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
var { UserList } = require('../user-list'); | |
module.exports = (req, res, next) => { | |
const username = req.get('username'); | |
const password = req.get('password'); | |
const user = UserList.find(user => user.username === username); | |
if (!user) { | |
req.isAuth = false; | |
return next(); | |
} |
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
var UserList = [ | |
{ | |
id: 1, | |
username: 'armin', | |
password: '12345', | |
}, | |
{ | |
id: 2, | |
username: 'fred', | |
password: '54321' |
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
var MoviesList = [ | |
{ | |
id: 1, | |
title: 'Avengers: Endgame', | |
rate: '8.7', | |
year: 2019 | |
}, | |
{ | |
id: 2, | |
title: 'John Wick: Chapter 3 - Parabellum', |
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
var { buildSchema } = require('graphql'); | |
var { MoviesList } = require('./movie-list'); | |
var schema = buildSchema(` | |
type Query { | |
movieInfo(id: Int!): Movie | |
movieList(rate: String): [Movie] | |
}, | |
type Movie { | |
id: Int |
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
var express = require('express'); | |
var express_graphql = require('express-graphql'); | |
var { schema, root} = require('./schema'); | |
var app = express(); | |
app.use('/graphql', express_graphql({ | |
schema: schema, | |
rootValue: root, | |
graphiql: true | |
})); |