Giter Site home page Giter Site logo

w3tecch / express-graphql-typescript-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
186.0 7.0 73.0 234 KB

A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch

License: MIT License

JavaScript 8.34% TypeScript 91.66%
typescript boilerplate graphql expressjs starter-kit backend api jasmine wallaby knex

express-graphql-typescript-boilerplate's People

Contributors

0xch4z avatar danbopes avatar hvish 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

express-graphql-typescript-boilerplate's Issues

Advantages of abstraction used

As a new user to this project, the organization of this repo's logic is very convoluted and hard to get a full picture. The README with the code structure helps but isn't enough. It would be helpful to better explain the abstraction choices made to help people understand how it all works together. It would also help to include examples of how to leverage those abstractions since a lot of them appear to be set up but not used in the sample app. Here are a few examples of my uncertainties:

  1. What is the difference between models.book.Attributes and models.book.RawAttributes? My understanding is they are used for serializing data to be put into the database (raw) and for serializing data coming out of DB (regular)? This would allow you to exclude some data from client responses or include additional data to be put into the DB. Is that accurate? If so, maybe change the two interfaces so there are some differences between the two that would allow the user to infer the purpose.
  2. There are getters/setters in the model. The setters aren't standard TypeScript set functions though. Why not? Also, all of the getters/setters simply update or read data with no additional logic, i.e. with the samples provided, the user doesn't see any benefit.
  3. What advantages are there of abstracting Context into its own class?

If there are any articles that explain the advantages of the above abstractions or the choices made to get these abstractions, please share.

Use external library for type definitions

GraphqlFieldConfig interface for defining types is glueing code definition with this very framework/boilerplate.

What do you think about using some external library like https://github.com/prismake/typegql

@ObjectType({ description: 'Simple product object type' })
class Product {
  @Field() name: string;

  @Field() price: number;

  @Field()
  isExpensive() {
    return this.price > 50;
  }
}

It allows you to define type in such way, but it still compiles to plain GraphQL object type that will work with every schema

Dataloaders aren't used

I'm trying to understand how the project all fits together and am failing to see how dataloaders defined in context/ are actually used. I see the dataloaders are attached to each GraphQL's request context but don't see them actually being used anywhere. Please correct me if I'm wrong.

Wont Build

Looks like a great project, but can't see all its goodness cause it won't build for me

No MySql, so trying 'sqlite3'. Just setting the connection string to be a file name. But I am not sure that is my problem, since it fails to even run the db:migrate script. Seems like a Knex issue.

With src/config.js
connection: 'mydb.sqlite', client: 'sqlite3',
and entering 'npm run db:migrate', i get this error

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'db:migrate' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'predb:migrate', 'db:migrate', 'postdb:migrate' ]
5 info lifecycle [email protected]predb:migrate: [email protected]
6 silly lifecycle [email protected]
predb:migrate: no script for predb:migrate, continuing
7 info lifecycle [email protected]db:migrate: [email protected]
8 verbose lifecycle [email protected]
db:migrate: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]db:migrate: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\node_modules.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Docker\Docker\Resources\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\Tools\Binn;C:\Program Files\Microsoft SQL Server\120\DTS\Binn;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;C:\Program Files\Microsoft SQL Server\110\Tools\Binn;C:\Users\Randy.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files (x86)\PuTTY;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Users\Randy\AppData\Local\Microsoft\WindowsApps;C:\Dev\Libs\Python;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\Randy\AppData\Local\GitHub\PortableGit_f02737a78695063deace08e96d5042710d3e32db\cmd;C:\Program Files\MongoDB\Server\3.4\bin;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Users\Randy\AppData\Roaming\npm;
10 verbose lifecycle [email protected]
db:migrate: CWD: C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master
11 silly lifecycle [email protected]db:migrate: Args: [ '/d /s /c', 'knex migrate:latest' ]
12 silly lifecycle [email protected]
db:migrate: Returned: code: 1 signal: null
13 info lifecycle [email protected]~db:migrate: Failed to exec db:migrate script
14 verbose stack Error: [email protected] db:migrate: knex migrate:latest
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:279:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:194:7)
14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:194:7)
14 verbose stack at maybeClose (internal/child_process.js:899:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master
17 error Windows_NT 10.0.15063
18 error argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "db:migrate"
19 error node v7.10.0
20 error npm v4.2.0
21 error code ELIFECYCLE
22 error errno 1
23 error [email protected] db:migrate: knex migrate:latest
23 error Exit status 1
24 error Failed at the [email protected] db:migrate script 'knex migrate:latest'.
24 error Make sure you have the latest version of node.js and npm installed.
24 error If you do, this is most likely a problem with the express-graphql-typescript-boilerplate package,
24 error not with npm itself.
24 error Tell the author that this fails on your system:
24 error knex migrate:latest
24 error You can get information on how to open an issue for this project with:
24 error npm bugs express-graphql-typescript-boilerplate
24 error Or if that isn't available, you can get their info via:
24 error npm owner ls express-graphql-typescript-boilerplate
24 error There is likely additional logging output above.
25 verbose exit [ 1, true ]

I tried running 'knex' but it was not recogized, so I loaded it globally.
Re-ran db:migrate script with same results.
Tried running 'knex migrate:latest' directly, and got this error

`
PS C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master> knex migrate:latest
Requiring external module ts-node/register

C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\node_modules\ts-node\src\index.ts:316
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
^
TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'fs-extra'. (2688)
Cannot find type definition file for 'handlebars'. (2688)
Cannot find type definition file for 'highlight.js'. (2688)
Cannot find type definition file for 'lodash'. (2688)
Cannot find type definition file for 'marked'. (2688)
Cannot find type definition file for 'minimatch'. (2688)
Cannot find type definition file for 'node'. (2688)
Cannot find type definition file for 'shelljs'. (2688)
knexfile.ts (3,16): Cannot find name 'require'. (2304)
knexfile.ts (7,1): Cannot find name 'module'. (2304)
at getOutput (C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\node_modules\ts-node\src\index.ts:316:17)
at C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\node_modules\ts-node\src\index.ts:347:18
at Object.compile (C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\node_modules\ts-node\src\index.ts:474:19)
at Module.m._compile (C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\node_modules\ts-node\src\index.ts:410:44
)
at Module._extensions..js (module.js:580:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master\no
de_modules\ts-node\src\index.ts:413:12)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at initKnex (C:\Users\Randy\AppData\Roaming\npm\node_modules\knex\bin\cli.js:50:16)
at Command. (C:\Users\Randy\AppData\Roaming\npm\node_modules\knex\bin\cli.js:127:17)
at Command.listener (C:\Users\Randy\AppData\Roaming\npm\node_modules\knex\node_modules\commander\index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:194:7)

`

Missing types!

Hey folks, I've noticed (actually my compiler did) there are some types missing. For example GraphQLFieldDefinition, GraphQLFieldDefinitionMap and GraphQLFieldResolveFn.

They are imported from graphql package but there are none of them, actually. Also, I didn't find any type augmentations related to these types. Soo, my question is: where are the types coming from? :)

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.