Skip to content

Instantly share code, notes, and snippets.

@nzaghini
nzaghini / server.js
Created June 29, 2018 08:07
Apollo Express setup for GraphQL with Context.
import express from 'express'
import { graphqlExpress, graphiqlExpress } from 'apollo-server-express'
import bodyParser from 'body-parser'
import schema from './src/schema'
import movieService from './src/dataSource/movieService'
const GRAPHQL_PORT = 3000
const graphQLServer = express()
@nzaghini
nzaghini / Movie-test.js
Last active September 23, 2022 17:03
Apollo GraphQL Test Example with Jest
import fs from 'fs'
import { makeExecutableSchema } from 'graphql-tools'
import { graphql } from 'graphql'
// the actual resolvers
import resolvers from '../src/resolvers'
// the mock service
import mockMovieService from './mocks/mockMovieService'
// a nice structure for test cases
// found at https://hackernoon.com/extensive-graphql-testing-57e8760f1c25