Coder Social home page Coder Social logo

intro-to-graphql's Introduction

Intro to GraphQL

Scott Moss & Frontend Masters

Resources

Course

This course has two parts, slides and excercises. The slides describe the excerices in detail. Each excercise has a starting branch and solution branch. Example lesson-1 and lesson-1-solution.

Excercises

Hello world GraphQL server with Apollo Server

  • branch - lesson-1

Note: ensure that you have MongoDB installed, and the server is running. See their website

In this lesson you'll be creating a simple GraphQL server using Apollo Server.

  • install dependencies with yarn (prefered for version locking) or npm
  • create a schema with at least one Type
  • create a query from that Type
  • create a mutation for that Type
  • create mock resolvers for query and mutation
  • start the server
  • using GraphQL playground, perform query and mutation

Creating Schema with SDL

  • branch - lesson-2
  • test command - yarn test-schema or npm run test-schema

This exercise will have you creating a GraphQL Schema based on the the mongoose models already created

  • create Type for product
  • create inputs for product
  • create queries for product
  • create mutations for product
  • ensure all tests pass by running test command

Resolving Queries and Mutations

  • branch - lesson-3
  • test command - yarn test-resolvers or npm run test-resolvers

In this exercise, you'll be creating resolvers for the Queries and Mutations on the product type. You'll be using Mongoose models to perform CRUD in your resolvers.

  • create resolvers for product queries
  • create resolvers for product mutations
  • create resolvers for prouduct createdBy field
  • ensure all tests pass by running test command

Interfaces and Unions

  • branch - lesson-4
  • test command - yarn test-interfaces or npm run test-interfaces

Now that you know about schemas and resolvers, we need to make some changes. Our product model in mongoose is split between 3 different product types. We need to make the product type an interface and then create types for each possible type in our mongoose model. Don't forget to create resolver to resolve the type.

  • change product type to an interface
  • create Bike type that implements product
  • create GamingPc type that implements product
  • create Drone type that implements product
  • create resolver for product interface that resolves the type
  • ensure all tests pass by running test command

Authentication

  • branch - lesson-5
  • test command - yarn test-auth or npm run test-auth

There are many many ways to authenticate with GraphQL. Our API is a public API, so we'll use API keys. Some queries need authentication, and some queries also need the correct role. Authenticate the request and update the product resolvers!

  • authenticate the request and add use to context
  • block all product queries and mutations if no user
  • block all product mutations if not an admin role
  • ensure all tests pass by running test command

Testing

The other types don't have any test, go ahead and write some!

intro-to-graphql's People

Contributors

1marc avatar hendrixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

intro-to-graphql's Issues

Add required versions of yarn and node on the README

While I was setting up the project I noticed this project doesn't play along with Yarn 1.22.*, I had to install 1.9.4. The same with Node, I had v14 installed and had to install v10.

If you think this is ok I can send a PR for it.

Cannot run lesson-2 tests

I am not able to run the tests associated with lesson 2. See terminal output below. Environment is Windows 10, Node 12.10

npm run test-schema

[email protected] test-schema C:\Users\mrsam\Projects\Education\intro-to-graphql
GQL_LESSON=lesson-2 npm test -- -t lesson-2

'GQL_LESSON' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test-schema: GQL_LESSON=lesson-2 npm test -- -t lesson-2
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test-schema script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\mrsam\AppData\Roaming\npm-cache_logs\2019-11-03T21_38_39_591Z-debug.log

cannot yarn dev

the server does not start, Mongo Network error.

$my comp yarn dev
yarn run v1.19.1
$ nodemon --exec yarn restart
[nodemon] 1.19.4
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter rs
[nodemon] or send SIGHUP to 7135 to restart
[nodemon] ignoring: ./.git//* node_modules//node_modules ./dist//*
[nodemon] watching dir(s): src/
/.js src/**/.graphql src/**/*.gql
[nodemon] watching extensions: js,json,graphql
[nodemon] starting yarn restart
[nodemon] spawning
[nodemon] child pid: 7137
[nodemon] watching 19 files
$ rimraf dist && yarn build && yarn start
$ babel src --out-dir dist
Successfully compiled 16 files with Babel.
$ node dist/index.js
(node:7146) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:7146) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1128:14) {
name: 'MongoNetworkError',
errorLabels: [Array],
[Symbol(mongoErrorContextSymbol)]: {}
}]
at Pool. (/Users/dannybyrne/CODE/intro-to-graphql/node_modules/mongodb/lib/core/topologies/server.js:433:11)
at Pool.emit (events.js:210:5)
at /Users/dannybyrne/CODE/intro-to-graphql/node_modules/mongodb/lib/core/connection/pool.js:562:14
at /Users/dannybyrne/CODE/intro-to-graphql/node_modules/mongodb/lib/core/connection/pool.js:985:11
at /Users/dannybyrne/CODE/intro-to-graphql/node_modules/mongodb/lib/core/connection/connect.js:40:11
at callback (/Users/dannybyrne/CODE/intro-to-graphql/node_modules/mongodb/lib/core/connection/connect.js:262:5)
at Socket. (/Users/dannybyrne/CODE/intro-to-graphql/node_modules/mongodb/lib/core/connection/connect.js:287:7)
at Object.onceWrapper (events.js:300:26)
at Socket.emit (events.js:210:5)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:7146) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7146) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[nodemon] clean exit - waiting for changes before restart

Lesson 1 Error: Type "Query" was defined more than once.

Following along with the first lesson and getting the following error.

Successfully compiled 16 files with Babel.
$ node dist/index.js
(node:87765) UnhandledPromiseRejectionWarning: Error: Type "Query" was defined more than once.
    at Object.buildASTSchema (/Users/iangoodrich/dev/experimental/intro-to-graphql/node_modules/graphql/utilities/buildASTSchema.js:84:15)
    at Object.buildSchemaFromTypeDefinitions (/Users/iangoodrich/dev/experimental/intro-to-graphql/node_modules/graphql-tools/dist/generate/buildSchemaFromTypeDefinitions.js:23:28)
    at Object.makeExecutableSchema (/Users/iangoodrich/dev/experimental/intro-to-graphql/node_modules/graphql-tools/dist/makeExecutableSchema.js:26:29)
    at new ApolloServerBase (/Users/iangoodrich/dev/experimental/intro-to-graphql/node_modules/apollo-server-core/dist/ApolloServer.js:150:43)
    at new ApolloServer (/Users/iangoodrich/dev/experimental/intro-to-graphql/node_modules/apollo-server-express/dist/ApolloServer.js:44:1)
    at new ApolloServer (/Users/iangoodrich/dev/experimental/intro-to-graphql/node_modules/apollo-server/dist/index.js:23:9)
    at start (/Users/iangoodrich/dev/experimental/intro-to-graphql/dist/server.js:47:18)
(node:87765) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:87765) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

lesson 1: Error: Cannot find module '.../dist/index.js'

In lesson 1, I get this error

yarn start
yarn run v1.16.0
$ node dist/index.js
internal/modules/cjs/loader.js:626
    throw err;
    ^

Error: Cannot find module '/Users/vincentleleux/introg/dist/index.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
error Command failed with exit code 1.

There is indeed no dist folder and the package.json got this line :
"start": "node dist/index.js"

so why is it not throwing an error for you ?

issues with install on windows

running into following errors while trying to install / run on windows 10 git bash

node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
Warning: unrecognized setting VCCLCompilerTool/MultiProcessorCompilation
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visual Studio 2005 or 3) add the location of the component to the system path if it is installed elsewhere.  [C:\dev\usr\intro-to-graphql\node_modules\bcrypt\build\binding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\user.name\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\user.name\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\dev\\usr\\intro-to-graphql\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\dev\\usr\\intro-to-graphql\\node_modules\\bcrypt\\lib\\binding" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\dev\usr\intro-to-graphql\node_modules\bcrypt
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\user.name\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\dev\usr\intro-to-graphql\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\dev\usr\intro-to-graphql\node_modules\bcrypt\lib\binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\dev\usr\intro-to-graphql\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:209:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.17134
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\dev\\usr\\intro-to-graphql\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\dev\usr\intro-to-graphql\node_modules\bcrypt
node-pre-gyp ERR! node -v v12.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\user.name\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\dev\usr\intro-to-graphql\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\dev\usr\intro-to-graphql\node_modules\bcrypt\lib\binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user.name\AppData\Roaming\npm-cache\_logs\2019-09-19T13_22_36_326Z-debug.log

user.name@machine-name MINGW64 /c/dev/usr/intro-to-graphql (master)
$ npm build
npm WARN build `npm build` called with no arguments. Did you mean to `npm run-script build`?

user.name@machine-name MINGW64 /c/dev/usr/intro-to-graphql (master)
$ npm run build

> [email protected] build C:\dev\usr\intro-to-graphql
> babel src --out-dir dist

Successfully compiled 16 files with Babel.

user.name@machine-name MINGW64 /c/dev/usr/intro-to-graphql (master)
$ npm run dev

> [email protected] dev C:\dev\usr\intro-to-graphql
> nodemon --exec yarn restart

[nodemon] 1.19.2
[nodemon] reading config .\nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 28268 to restart
[nodemon] ignoring: .\.git/**/* node_modules/**/node_modules .\dist/**/*
[nodemon] watching dir(s): src\**\*.js src\**\*.graphql src\**\*.gql
[nodemon] watching extensions: js,json,graphql
[nodemon] starting `yarn restart`
[nodemon] spawning
[nodemon] child pid: 15696
[nodemon] watching 19 files
yarn run v1.17.3
$ rimraf dist && yarn build && yarn start
$ babel src --out-dir dist
Successfully compiled 16 files with Babel.
$ node dist/index.js
internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module 'bcrypt'
Require stack:
- C:\dev\usr\intro-to-graphql\dist\types\user\user.model.js
- C:\dev\usr\intro-to-graphql\dist\utils\auth.js
- C:\dev\usr\intro-to-graphql\dist\server.js
- C:\dev\usr\intro-to-graphql\dist\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (C:\dev\usr\intro-to-graphql\dist\types\user\user.model.js:10:38)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at Object.<anonymous> (C:\dev\usr\intro-to-graphql\dist\utils\auth.js:8:13)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)
    at Function.Module._load (internal/modules/cjs/loader.js:703:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\dev\\usr\\intro-to-graphql\\dist\\types\\user\\user.model.js',
    'C:\\dev\\usr\\intro-to-graphql\\dist\\utils\\auth.js',
    'C:\\dev\\usr\\intro-to-graphql\\dist\\server.js',
    'C:\\dev\\usr\\intro-to-graphql\\dist\\index.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[nodemon] app crashed - waiting for file changes before starting...

Lesson 2: "Product has base fields" test is flawed

Test "Product has base fields" tests only that the included fields are the right type and not that all required fields are present. Due to this, the test will still pass even though the Product schema is missing some fields like description or createdBy.

type Product {
name: String!
price: Float!
image: String!
type: ProductType!
range: String
liquidCooled: Boolean
bikeType: BikeType
}
...

RUNS src/types/product/tests/product.type.spec.js
PASS src/types/product/tests/product.type.spec.jsec.js
Product schema
lesson-2:
✓ Product has base fields (366ms)
✓ NewProductInput has correct fields (15ms)
✓ UpdateProductInput has correct fields (10ms)
✓ product query (45ms)
✓ products query (18ms)
✓ newProduct mutation (22ms)
✓ updateProduct mutation (19ms)
✓ removeProduct mutation (15ms)

Can't run "yarn"

$ yarn
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "apollo-server > apollo-server-core > @apollographql/[email protected]" has incorrect peer dependency "graphql@^0.13.1".
[4/4] Building fresh packages...
[1/3] ⠄ protobufjs
[2/3] ⠄ bcrypt
error C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | win32 | x64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding\bcrypt_lib.node" (not found)
node-pre-gyp http GET https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp http 404 https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.2/bcrypt_lib-v3.0.2-node-v72-win32-x64-unknown.tar.gz

C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\binn
ode-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node "" clean )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info ok

C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" configure --fallback-to-build --module=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding
--napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 ) else (node "" configure --fallback-to-build --module=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-r
aphql-lesson-1\node_modules\bcrypt\lib\binding --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 )
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.8.5 found at "C:\Python38\python.exe"
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:310:5)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt
gyp ERR! node -v v12.18.3
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Windows_NT 10.0.18363
node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt
node-pre-gyp ERR! node -v v12.18.3
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\danie\Desktop\Desenvolvimento\FrontEndMasters\intro-to-graphql-lesson-1\node_modules\bcrypt\lib\binding --napi_version=6 --node_ab

*EDIT: Got it working by following these instructions:
Run: npm install -g node-gyp
then: npm install bcrypt

Stackoverflow link: https://stackoverflow.com/questions/29320201/error-installing-bcrypt-with-npm

MongoError: topology was destroyed

When running test-schema script on branch lesson-2-solution with installed dependencies and mongod running in a terminal I have this error:
Jest's output:
Product schema › lesson-2: › Product has base fields

MongoError: topology was destroyed

  at createIndex (node_modules/mongodb/lib/operations/db_ops.js:289:21)
  at indexInformation (node_modules/mongodb/lib/operations/db_ops.js:424:7)
  at db.collection.listIndexes.toArray (node_modules/mongodb/lib/operations/db_ops.js:579:23)
  at err (node_modules/mongodb/lib/utils.js:415:14)
  at executeCallback (node_modules/mongodb/lib/utils.js:404:25)
  at handleCallback (node_modules/mongodb/lib/utils.js:128:55)
  at cursor._endSession.cursor._endSession (node_modules/mongodb/lib/operations/cursor_ops.js:220:38)
  at ClientSession.endSession (node_modules/mongodb-core/lib/sessions.js:113:43)
  at CommandCursor.Object.<anonymous>.Cursor._endSession (node_modules/mongodb-core/lib/cursor.js:190:13)
  at CommandCursor.Object.<anonymous>.Cursor._endSession (node_modules/mongodb/lib/cursor.js:226:59)
  at cursor._next (node_modules/mongodb/lib/operations/cursor_ops.js:220:20)
  at queryCallback (node_modules/mongodb-core/lib/cursor.js:660:23)
  at node_modules/mongodb-core/lib/connection/pool.js:532:18

$ mongod --version
db version v4.0.5
git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
allocator: tcmalloc
modules: none
build environment:
distmod: 2008plus-ssl
distarch: x86_64
target_arch: x86_64

What could be the suggestion for resolving this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.