{"size": 1009, "ext": "js", "max_stars_repo_path": "example/server.js", "max_stars_repo_name": "Eyezon/flat2hier-graphql", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "example/server.js", "max_issues_repo_name": "Eyezon/flat2hier-graphql", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "example/server.js", "max_forks_repo_name": "Eyezon/flat2hier-graphql", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 16.8166666667, "max_line_length": 80, "alphanum_fraction": 0.6134786918}
const express = require('express')
const graphqlHTTP = require('express-graphql')

const { schema, rootResolver } = require('./graphql')


const app = express()

app.use('/graphql', graphqlHTTP({
    schema,
    rootValue: rootResolver,
    graphiql: true,
}));

const PORT = process.env.NODE_ENV || 3000
app.listen(PORT, err => {
    if (err) {
        console.error('Failed to start server', err)
    } else {
        console.log('Server started at port:', PORT)
    }
})

/*
CURL CMD FOR TESTING
(U may pipe curl to jq[https://stedolan.github.io/jq/] for nicely formated json)

1.

curl -XPOST -H "Content-Type:application/graphql"  -d ' 
query {
    allDrivers{
    id
    firstName
    lastName
    assignedCars {
      id
      name
      licenseNo
      addedAt
    }
  }
}' http://localhost:3000/graphql

2.

curl -XPOST -H "Content-Type:application/graphql"  -d ' 
query {
    driver(id: 1){
    id
    firstName,
    assignedCars {
      id
      name
    }
  }
}' http://localhost:3000/graphql

*/
