w3tecch / express-graphql-typescript-boilerplate Goto Github PK
View Code? Open in Web Editor NEWA starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
License: MIT License
A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
License: MIT License
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:
If there are any articles that explain the advantages of the above abstractions or the choices made to get these abstractions, please share.
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
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.
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]predb:migrate: no script for predb:migrate, continuing
6 silly lifecycle [email protected]
7 info lifecycle [email protected]db:migrate: [email protected]db:migrate: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
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;db:migrate: CWD: C:\Dev\Play\graphQL\express-graphql-typescript-boilerplate-master
10 verbose lifecycle [email protected]
11 silly lifecycle [email protected]db:migrate: Args: [ '/d /s /c', 'knex migrate:latest' ]db:migrate: Returned: code: 1 signal: null
12 silly lifecycle [email protected]
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)
`
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? :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.