Create a folder i.e graphql-local-server
initialize package.json with following command. we just keep all defaults with it.
Add a start script to your package.json file
Install babel dependencies.
Run following commands in order to install latest version of babel compiler and babel preset
npm install babel-cli babel-preset-env
babel-cli is a babel compiler and babel-preset-env will tell babel what it should change so the browser can understand the JS code.
Now create a single file called .babelrc in your root folder which will tell our presets which environment to use.
npm install graphql-yoga
create an index.js file inside your src root folder with following content.
Now when you run
npm run start
you will see the log with "The server is up!" text.
By default, graphql-yoga starts the server on port 4000
Open the http://localhost:4000/ to see your first graphQL api.