A high performance GraphQL adapter for SQL and non-SQL databases.
Configuring the adapter
You can configure Feathers services using the @feathers-plus/graphql adapter as shown in the docs. The adapter can be configured to use either
- normal Feathers services,
- Feathers services with BatchLoaders, or
- raw SQL statements.
Press the appropriate
Show button in the docs to see the relevant code.
As you can see, the adapter requires multiple working parts in order to configure the GraphQL instance properly. That's just how GraphQL is.
The examples are:
|folder name||language||database||resolver functions|
|ts-nedb-services||TypeScript||NeDB||plain Feathers calls|
|ts-sequelize-services||TypeScript||Sequelize + SQLite||plain Feathers calls|
|ts-sequelize-batchloaders||TypeScript||Sequelize + SQLite||BatchLoader calls|
|ts-sequelize-sql||TypeScript||Sequelize + SQLite||raw SQL statements|
You will find that you need to write lots of resolver functions for a non-trivial app. For some insight, look at this relatively simple example involving just 5 tables.
Most of the effort in using GraphQL will be devoted to writing lots of resolver functions.
The above example uses normal Feathers service calls, without caching, without batching. You would see an approximate ten-fold performance improvement is you used Feathers service calls in conjunction with BatchLoaders. These types of resolver functions would be more complicated.
Finally, you may consider resolver functions which produce raw SQL statements if you are using an SQL database with Sequelize or Knex. This may very well result in a performance improvement over BatchLoaders but you would have to use something like join-monster along with resolver functions.
Generating Resolver Functions
@feathers-plus/cli, a.k.a. cli+, was written to automatically generate the resolver functions for you. You can customize the resulting resolver code if necessary.
The examples in @feathers-plus/cli-generate-example were all written with cli+ and you can use cli+ to modify them.
REST and GraphQL
REST and GraphQL are totally different. Each is dope if used for the right thing.
FeathersJS, using cli+, now supports both REST and GraphQL architectural concepts and their query languages.
Copyright (c) 2018
Licensed under the MIT license.