Graphback: SQLite is not working without manual changes

Created on 21 Sep 2019  ยท  4Comments  ยท  Source: aerogear/graphback

I've tried to create a new project using sqlite as database but I have to manually modify the graphback.json to make it works. Also if I change the sqlite path the db will be always created in the same place.

โžœ  graphql-testx git:(examples) โœ— graphback init graphtest                       
   ____                          _       _                      _    
  / ___|  _ __    __ _   _ __   | |__   | |__     __ _    ___  | | __
 | |  _  | '__|  / _` | | '_ \  | '_ \  | '_ \   / _` |  / __| | |/ /
 | |_| | | |    | (_| | | |_) | | | | | | |_) | | (_| | | (__  |   < 
  \____| |_|     \__,_| | .__/  |_| |_| |_.__/   \__,_|  \___| |_|\_\
                        |_|                                          
? Choose a template to bootstrap apollo-starter-ts
? Do you want to include a example model? Yes
? Choose one of the example models Note
? Choose your database sqlite3
? Do you want to generate client-side queries? No

Bootstraping graphql server ๐Ÿ’ซ โœจ
โœ” Downloading starter from https://api.github.com/repos/aerogear/graphback/tarball/master
โœ” Extracting content to /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest
โœ” Creating model
โœ” Installing dependencies

GraphQL server successfully bootstrapped ๐Ÿš€
Next Steps:
1. Change directory into project folder - cd graphtest
2. Edit the .graphql file inside model with your GraphQL types.
3. Run graphback generate to generate schema and resolvers
4. Run docker-compose up -d to run your database
   and graphback db to create database resources in postgres

โžœ  graphql-testx git:(examples) โœ— cd graphtest                     
โžœ  graphtest git:(examples) โœ— graphback generate      

Successfully generated schema and resolvers ๐ŸŽ‰.  

Next steps:
1. Run docker-compose up -d or docker-compose start 
   followed by graphback db to create database.
2. Run npm run develop to start the server.

โžœ  graphtest git:(examples) โœ— graphback db      
sqlite does not support inserting default values. Set the `useNullAsDefault` flag to hide this warning. (see docs http://knexjs.org/#Builder-insert).
SQLite3 Foreign & Primary keys may only be added on create

Database resources created.
Run graphback watch to start the server and watch for changes.

โžœ  graphtest git:(examples) โœ— npm run develop

> [email protected] develop /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest
> ts-node src/index.ts

Knex: run
$ npm install pg --save
Cannot find module 'pg'
Error: Cannot find module 'pg'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Client_PG._driver (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/dialects/postgres/index.js:48:12)
    at Client_PG.initializeDriver (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/client.js:221:26)
    at Client_PG.Client (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/client.js:59:10)
    at new Client_PG (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/dialects/postgres/index.js:15:10)
    at Object.Knex [as default] (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/knex.js:52:28)
    at Object.<anonymous> (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/db.ts:5:14)
    at Generator.next (<anonymous>)
    at /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/tslib/tslib.js:106:16)
    at Object.connect (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/db.ts:7:20)
    at /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/index.ts:20:24
(node:5307) UnhandledPromiseRejectionWarning: Error: Knex: run
$ npm install pg --save
Cannot find module 'pg'
    at Client_PG.initializeDriver (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/client.js:225:13)
    at Client_PG.Client (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/client.js:59:10)
    at new Client_PG (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/dialects/postgres/index.js:15:10)
    at Object.Knex [as default] (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/knex/lib/knex.js:52:28)
    at Object.<anonymous> (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/db.ts:5:14)
    at Generator.next (<anonymous>)
    at /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/tslib/tslib.js:106:16)
    at Object.connect (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/db.ts:7:20)
    at /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/index.ts:20:24
    at Generator.next (<anonymous>)
    at /home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/tslib/tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/node_modules/tslib/tslib.js:106:16)
    at start (/home/dbizzarr/Projects/github.com/aerogear/graphql-testx/graphtest/src/index.ts:13:20)
(node:5307) 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: 2)
(node:5307) [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.

Most helpful comment

@b1zzu tests are added and we do code generation on the fly - with compilation efforts.
This is still not runtime. Codebase now tests SQLLite exclusively so it should work

All 4 comments

This is due to master moving to a different format without release.
We need to release as soon as possible. Need to get another PR to master first.

@wtrocki do we have tests for the cli? Maybe we should have some basic integration tests (also in bash) that test the starter with the different combinations

We do not and we need them badly. Going to prioritize that.

@b1zzu tests are added and we do code generation on the fly - with compilation efforts.
This is still not runtime. Codebase now tests SQLLite exclusively so it should work

Was this page helpful?
0 / 5 - 0 ratings