@common-stack/generate-plugin 5.0.4-alpha.9 → 5.0.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +42 -0
- package/generators.json +5 -0
- package/lib/generators/add-backend/files/CHANGELOG.md +196 -0
- package/lib/generators/add-backend/files/Dockerfile +30 -0
- package/lib/generators/add-backend/files/LICENSE +661 -0
- package/lib/generators/add-backend/files/README.md +133 -0
- package/lib/generators/add-backend/files/__tests__/test.ts.template +95 -0
- package/lib/generators/add-backend/files/babel.config.js +45 -0
- package/lib/generators/add-backend/files/build.config.js +14 -0
- package/lib/generators/add-backend/files/build.config.mjs +27 -0
- package/lib/generators/add-backend/files/generated-schema.graphql +235 -0
- package/lib/generators/add-backend/files/jest.config.js +27 -0
- package/lib/generators/add-backend/files/knexfile.js +63 -0
- package/lib/generators/add-backend/files/package.json +162 -0
- package/lib/generators/add-backend/files/src/api/remote-config.ts.template +11 -0
- package/lib/generators/add-backend/files/src/api/resolver.ts.template +15 -0
- package/lib/generators/add-backend/files/src/api/root-schema.graphqls +96 -0
- package/lib/generators/add-backend/files/src/api/scalar.ts.template +16 -0
- package/lib/generators/add-backend/files/src/api/schema-builder.ts.template +189 -0
- package/lib/generators/add-backend/files/src/api/utils.ts.template +44 -0
- package/lib/generators/add-backend/files/src/config/env-config.ts.template +34 -0
- package/lib/generators/add-backend/files/src/config/index.ts.template +1 -0
- package/lib/generators/add-backend/files/src/config/moleculer.config.ts.template +228 -0
- package/lib/generators/add-backend/files/src/connectors/connection-broker.ts.template +80 -0
- package/lib/generators/add-backend/files/src/connectors/graphql-pubsub-connector.ts.template +43 -0
- package/lib/generators/add-backend/files/src/connectors/mongo-connector.ts.template +78 -0
- package/lib/generators/add-backend/files/src/connectors/nats-connector.ts.template +82 -0
- package/lib/generators/add-backend/files/src/connectors/redis-connector.ts.template +73 -0
- package/lib/generators/add-backend/files/src/env.ts.template +5 -0
- package/lib/generators/add-backend/files/src/express-app.ts.template +67 -0
- package/lib/generators/add-backend/files/src/index.ts.template +56 -0
- package/lib/generators/add-backend/files/src/interfaces/index.ts.template +1 -0
- package/lib/generators/add-backend/files/src/interfaces/module-interface.ts.template +16 -0
- package/lib/generators/add-backend/files/src/main.spec.ts.template +129 -0
- package/lib/generators/add-backend/files/src/middleware/__tests__/cors.test.ts.template +12 -0
- package/lib/generators/add-backend/files/src/middleware/cors.ts.template +31 -0
- package/lib/generators/add-backend/files/src/middleware/error.ts.template +63 -0
- package/lib/generators/add-backend/files/src/middleware/moleculer-inter-namespace.ts.template +60 -0
- package/lib/generators/add-backend/files/src/middleware/persistedQuery.ts.template +40 -0
- package/lib/generators/add-backend/files/src/middleware/sentry.ts.template +9 -0
- package/lib/generators/add-backend/files/src/middleware/services.ts.template +16 -0
- package/lib/generators/add-backend/files/src/middleware/tracer.ts.template +24 -0
- package/lib/generators/add-backend/files/src/modules/auth/schema/auth-schema.graphql +25 -0
- package/lib/generators/add-backend/files/src/modules/index.ts.template +17 -0
- package/lib/generators/add-backend/files/src/modules/module.ts.template +78 -0
- package/lib/generators/add-backend/files/src/server-setup/graphql-server.ts.template +185 -0
- package/lib/generators/add-backend/files/src/server-setup/graphql-subscription-server.ts.template +113 -0
- package/lib/generators/add-backend/files/src/server-setup/graphql-ws.ts.template +158 -0
- package/lib/generators/add-backend/files/src/server-setup/mongodb-migration-update.ts.template +47 -0
- package/lib/generators/add-backend/files/src/server-setup/utils.ts.template +43 -0
- package/lib/generators/add-backend/files/src/server-setup/websocket-multipath-update.ts.template +88 -0
- package/lib/generators/add-backend/files/src/service.ts.template +36 -0
- package/lib/generators/add-backend/files/src/stack-server.ts.template +277 -0
- package/lib/generators/add-backend/files/src/utils/migrations.ts.template +32 -0
- package/lib/generators/add-backend/files/tsconfig.base.json +30 -0
- package/lib/generators/add-backend/files/tsconfig.json +19 -0
- package/lib/generators/add-backend/files/uploads/3986781.ppt +0 -0
- package/lib/generators/add-backend/files/webpack.config.js +186 -0
- package/lib/generators/add-backend/files/webpack.config.mjs +209 -0
- package/lib/generators/add-backend/generator.cjs +20 -0
- package/lib/generators/add-backend/generator.cjs.map +1 -0
- package/lib/generators/add-backend/generator.d.ts +4 -0
- package/lib/generators/add-backend/generator.mjs +20 -0
- package/lib/generators/add-backend/generator.mjs.map +1 -0
- package/lib/generators/add-backend/generator.spec.d.ts +1 -0
- package/lib/generators/add-backend/schema.json +17 -0
- package/lib/generators/add-frontend/generator.cjs +3 -12
- package/lib/generators/add-frontend/generator.cjs.map +1 -1
- package/lib/generators/add-frontend/generator.mjs +2 -11
- package/lib/generators/add-frontend/generator.mjs.map +1 -1
- package/lib/generators/add-frontend/templates/package.json +23 -24
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +1 -1
- package/lib/utils/index.cjs +8 -0
- package/lib/utils/index.cjs.map +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.mjs +8 -0
- package/lib/utils/index.mjs.map +1 -0
- package/package.json +2 -2
- package/rollup.config.mjs +6 -4
- package/src/generators/add-backend/generator.spec.ts +20 -0
- package/src/generators/add-backend/generator.ts +30 -0
- package/src/generators/add-backend/schema.d.ts +4 -0
- package/src/generators/add-backend/schema.json +17 -0
- package/src/generators/add-frontend/generator.ts +2 -12
- package/src/index.ts +1 -1
- package/src/utils/index.ts +10 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# webpack-apollo-server
|
|
2
|
+
Starter kit for apollo server using webpack and typescript
|
|
3
|
+
|
|
4
|
+
What does it include:
|
|
5
|
+
----
|
|
6
|
+
1. exported schema as example for GraphQL Schema
|
|
7
|
+
2. Working Apollo Server (webpack + tslint + tsloader)
|
|
8
|
+
3. Typescript 2.0.0 => ES6
|
|
9
|
+
4. Dockerfile to make the apollo-server a container.
|
|
10
|
+
5. unit testing (mocha-webpack+chai) + coverage report (mocha-istanbul-spec+istanbul).
|
|
11
|
+
6. working with graphql-tools
|
|
12
|
+
7. standard-version for auto SemVer.
|
|
13
|
+
|
|
14
|
+
Notes
|
|
15
|
+
----
|
|
16
|
+
Please note that you will need to rename the library name in some files:
|
|
17
|
+
|
|
18
|
+
1. package.json (ofcourse ;))
|
|
19
|
+
|
|
20
|
+
Useful commands:
|
|
21
|
+
----
|
|
22
|
+
yarn build - build the library files (Required for start:watch)
|
|
23
|
+
yarn build:watch - build the library files in watchmode (Useful for development)
|
|
24
|
+
npm test - run tests once
|
|
25
|
+
yarn test:watch - run tests in watchmode (Useful for development)
|
|
26
|
+
yarn test:growl - run tests in watchmode with growl notification (even more useful for development)
|
|
27
|
+
|
|
28
|
+
How to run it:
|
|
29
|
+
----
|
|
30
|
+
```bash
|
|
31
|
+
npm start
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Files explained:
|
|
35
|
+
----
|
|
36
|
+
1. src - directory is used for typescript code that is part of the project
|
|
37
|
+
1a. main.ts - Main server file. (Starting Apollo server)
|
|
38
|
+
1b. main.spec.ts - Tests file for main
|
|
39
|
+
1c. schema - Module used to build schema
|
|
40
|
+
- index.ts - simple logic to merge all modules into a schema using graphql-tools
|
|
41
|
+
- modules/ - directory for modules to be used with graphql-tools
|
|
42
|
+
1c. schema.spec.ts - Basic test for schema.
|
|
43
|
+
1c. main.test.ts - Main for tests runner.
|
|
44
|
+
3. package.json - file is used to describe the library
|
|
45
|
+
4. tsconfig.json - configuration file for the library compilation
|
|
46
|
+
6. tslint.json - configuration file for the linter
|
|
47
|
+
7. typings.json - typings needed for the server
|
|
48
|
+
8. webpack.config.js - configuration file of the compilation automation process for the library
|
|
49
|
+
9. webpack.config.test.js - configuration file of the compilation when testing
|
|
50
|
+
10. Dockerfile - Dockerfile used to describe how to make a container out of apollo server
|
|
51
|
+
11. mocha-webpack.opts - Options file for mocha-webpack
|
|
52
|
+
|
|
53
|
+
Output files explained:
|
|
54
|
+
----
|
|
55
|
+
1. node_modules - directory npm creates with all the dependencies of the module (result of yarn install)
|
|
56
|
+
2. dist - directory contains the compiled server (javascript)
|
|
57
|
+
3. html-report - output of npm test, code coverage html report.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Database
|
|
61
|
+
----
|
|
62
|
+
Connects to memory database through Knex
|
|
63
|
+
|
|
64
|
+
Database configuration is set in `db-config.json`
|
|
65
|
+
|
|
66
|
+
Setup
|
|
67
|
+
----
|
|
68
|
+
Create a database and fill the data
|
|
69
|
+
```
|
|
70
|
+
yarn db:seed
|
|
71
|
+
```
|
|
72
|
+
What files to be customized?
|
|
73
|
+
----
|
|
74
|
+
Customizable files for a specific project would be the following
|
|
75
|
+
```
|
|
76
|
+
src/container
|
|
77
|
+
src/middleware/graphql.ts
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The Person type - dynamic/parametrized query and drill down:
|
|
81
|
+
----
|
|
82
|
+
The person type was added to demonstrate a database like access, parametrized queries, resolvers and drill down.
|
|
83
|
+
The data is currently hard coded but simulates a storage. Each person has an id, name and sex. It also has a dynamic
|
|
84
|
+
field called matches. For demonstration purposes, this field will retrieve all members of the other sex by using a
|
|
85
|
+
resolver.
|
|
86
|
+
|
|
87
|
+
Since this is a computed field the query can be infinitely nested, for example, try in the graphiql editor this query:
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
getPerson(id: "1") {
|
|
91
|
+
id,
|
|
92
|
+
name
|
|
93
|
+
sex
|
|
94
|
+
matches {
|
|
95
|
+
id
|
|
96
|
+
name
|
|
97
|
+
sex
|
|
98
|
+
matches {
|
|
99
|
+
id
|
|
100
|
+
name
|
|
101
|
+
sex
|
|
102
|
+
matches {
|
|
103
|
+
id
|
|
104
|
+
name
|
|
105
|
+
sex
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
It will return a nested, alternating male/femal results.
|
|
113
|
+
|
|
114
|
+
To list all persons, use the `persons` query:
|
|
115
|
+
|
|
116
|
+
{
|
|
117
|
+
persons {
|
|
118
|
+
id
|
|
119
|
+
name
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
There is also an example of a mutation - `addPerson(name: String, sex: String)`, to use it:
|
|
124
|
+
|
|
125
|
+
mutation {
|
|
126
|
+
addPerson(name: "kuku", sex: "male"){
|
|
127
|
+
id
|
|
128
|
+
name
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
Note that the query generates a random id and that the added persons are transient,
|
|
133
|
+
i.e. not persisted and will be gone once you shut down the server.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createServer } from "http";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import { ApolloServer, gql } from "apollo-server-express";
|
|
4
|
+
import { ApolloServerPluginDrainHttpServer } from "apollo-server-core";
|
|
5
|
+
import { PubSub } from "graphql-subscriptions";
|
|
6
|
+
import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
7
|
+
import { WebSocketServer } from "ws";
|
|
8
|
+
import { useServer } from "graphql-ws/lib/use/ws";
|
|
9
|
+
|
|
10
|
+
const PORT = 8080;
|
|
11
|
+
const pubsub = new PubSub();
|
|
12
|
+
|
|
13
|
+
// Schema definition
|
|
14
|
+
const typeDefs = gql`
|
|
15
|
+
type Query {
|
|
16
|
+
currentNumber: Int
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Subscription {
|
|
20
|
+
numberIncremented: Int
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
// Resolver map
|
|
25
|
+
const resolvers = {
|
|
26
|
+
Query: {
|
|
27
|
+
currentNumber() {
|
|
28
|
+
return currentNumber;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
Subscription: {
|
|
32
|
+
numberIncremented: {
|
|
33
|
+
subscribe: () => pubsub.asyncIterator(["NUMBER_INCREMENTED"]),
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Create schema, which will be used separately by ApolloServer and
|
|
39
|
+
// the WebSocket server.
|
|
40
|
+
const schema = makeExecutableSchema({ typeDefs, resolvers });
|
|
41
|
+
console.log('--schema--', schema)
|
|
42
|
+
// Create an Express app and HTTP server; we will attach the WebSocket
|
|
43
|
+
// server and the ApolloServer to this HTTP server.
|
|
44
|
+
const app = express();
|
|
45
|
+
const httpServer = createServer(app);
|
|
46
|
+
|
|
47
|
+
// Set up WebSocket server.
|
|
48
|
+
const wsServer = new WebSocketServer({
|
|
49
|
+
server: httpServer,
|
|
50
|
+
path: "/graphql",
|
|
51
|
+
});
|
|
52
|
+
const serverCleanup = useServer({ schema }, wsServer);
|
|
53
|
+
|
|
54
|
+
// Set up ApolloServer.
|
|
55
|
+
const server = new ApolloServer({
|
|
56
|
+
schema,
|
|
57
|
+
plugins: [
|
|
58
|
+
// Proper shutdown for the HTTP server.
|
|
59
|
+
ApolloServerPluginDrainHttpServer({ httpServer }),
|
|
60
|
+
|
|
61
|
+
// Proper shutdown for the WebSocket server.
|
|
62
|
+
{
|
|
63
|
+
async serverWillStart() {
|
|
64
|
+
return {
|
|
65
|
+
async drainServer() {
|
|
66
|
+
await serverCleanup.dispose();
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
await server.start();
|
|
74
|
+
server.applyMiddleware({ app });
|
|
75
|
+
|
|
76
|
+
// Now that our HTTP server is fully set up, actually listen.
|
|
77
|
+
httpServer.listen(PORT, () => {
|
|
78
|
+
console.log(
|
|
79
|
+
`🚀 Query endpoint ready at http://localhost:${PORT}${server.graphqlPath}`
|
|
80
|
+
);
|
|
81
|
+
console.log(
|
|
82
|
+
`🚀 Subscription endpoint ready at ws://localhost:${PORT}${server.graphqlPath}`
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// In the background, increment a number every second and notify subscribers when
|
|
87
|
+
// it changes.
|
|
88
|
+
let currentNumber = 0;
|
|
89
|
+
function incrementNumber() {
|
|
90
|
+
currentNumber++;
|
|
91
|
+
pubsub.publish("NUMBER_INCREMENTED", { numberIncremented: currentNumber });
|
|
92
|
+
setTimeout(incrementNumber, 10000);
|
|
93
|
+
}
|
|
94
|
+
// Start incrementing
|
|
95
|
+
incrementNumber();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
process.env.ENV_FILE !== null && require('dotenv').config({ path: process.env.ENV_FILE });
|
|
2
|
+
|
|
3
|
+
module.exports = (api) => {
|
|
4
|
+
const isBabelRegister = api.caller((caller) => caller && caller.name === '@babel/register');
|
|
5
|
+
const isTest = api.env('test');
|
|
6
|
+
api.cache(true);
|
|
7
|
+
if (isTest || isBabelRegister) {
|
|
8
|
+
return {
|
|
9
|
+
presets: [
|
|
10
|
+
'@babel/preset-typescript',
|
|
11
|
+
'@babel/preset-react',
|
|
12
|
+
['@babel/preset-env', { targets: { node: true }, modules: 'commonjs' }],
|
|
13
|
+
],
|
|
14
|
+
plugins: [
|
|
15
|
+
'babel-plugin-dynamic-import-node',
|
|
16
|
+
'@babel/plugin-proposal-class-properties',
|
|
17
|
+
'@babel/plugin-proposal-optional-chaining',
|
|
18
|
+
'babel-plugin-import-graphql',
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
compact: false,
|
|
24
|
+
presets: [
|
|
25
|
+
'@babel/preset-typescript',
|
|
26
|
+
'@babel/preset-react',
|
|
27
|
+
['@babel/preset-env', { targets: { node: true }, modules: false }],
|
|
28
|
+
],
|
|
29
|
+
plugins: [
|
|
30
|
+
'babel-plugin-dynamic-import-node',
|
|
31
|
+
'@loadable/babel-plugin',
|
|
32
|
+
'@babel/plugin-transform-destructuring',
|
|
33
|
+
'@babel/plugin-transform-runtime',
|
|
34
|
+
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
35
|
+
'@babel/plugin-proposal-class-properties',
|
|
36
|
+
'@babel/plugin-proposal-object-rest-spread',
|
|
37
|
+
'@babel/plugin-proposal-optional-chaining',
|
|
38
|
+
],
|
|
39
|
+
env: {
|
|
40
|
+
production: {
|
|
41
|
+
compact: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
process.env.ENV_FILE !== null && require('dotenv').config({ path: process.env.ENV_FILE });
|
|
2
|
+
const config = {
|
|
3
|
+
...require('../../build.config'),
|
|
4
|
+
__CLIENT__: false,
|
|
5
|
+
__SERVER__: true,
|
|
6
|
+
__DEV__: process.env.NODE_ENV !== 'production',
|
|
7
|
+
__TEST__: false,
|
|
8
|
+
'process.env.NODE_ENV': process.env.NODE_ENV || 'development',
|
|
9
|
+
__GRAPHQL_URL__: process.env.GRAPHQL_URL || '/graphql',
|
|
10
|
+
__CDN_URL__: process.env.CDN_URL || '',
|
|
11
|
+
__FRONTEND_BUILD_DIR__: process.env.FRONTEND_BUILD_DIR || '../frontend-server/dist/web',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
module.exports = config;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
if (process.env.ENV_FILE !== null) {
|
|
2
|
+
import('dotenv').then(({ config }) =>
|
|
3
|
+
config({ path: process.env.ENV_FILE })
|
|
4
|
+
);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const __API_SERVER_PORT__ = process.env.GRAPHQL_URL ? new URL(process.env.GRAPHQL_URL).port : 8080;
|
|
8
|
+
const __SERVER_PROTOCOL__ = 'http';
|
|
9
|
+
const __LOCAL_SERVER_HOST__ = 'localhost';
|
|
10
|
+
const __GRAPHQL_ENDPOINT__ = process.env.GRAPHQL_URL ? new URL(process.env.GRAPHQL_URL).pathname : '/graphql';
|
|
11
|
+
|
|
12
|
+
const config = {
|
|
13
|
+
__CLIENT__: false,
|
|
14
|
+
__SERVER__: true,
|
|
15
|
+
__DEV__: process.env.NODE_ENV !== 'production',
|
|
16
|
+
__TEST__: false,
|
|
17
|
+
'process.env.NODE_ENV': process.env.NODE_ENV || 'development',
|
|
18
|
+
__GRAPHQL_URL__: process.env.GRAPHQL_URL || '/graphql',
|
|
19
|
+
__CDN_URL__: process.env.CDN_URL || '',
|
|
20
|
+
__FRONTEND_BUILD_DIR__: process.env.FRONTEND_BUILD_DIR || '../frontend-server/dist/web',
|
|
21
|
+
__API_SERVER_PORT__,
|
|
22
|
+
__GRAPHQL_ENDPOINT__,
|
|
23
|
+
__LOCAL_SERVER_HOST__,
|
|
24
|
+
__API_URL__: process.env.API_URL || `${__SERVER_PROTOCOL__}://${__LOCAL_SERVER_HOST__}:${__API_SERVER_PORT__}${__GRAPHQL_ENDPOINT__}`,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default config;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Address City Interface
|
|
3
|
+
"""
|
|
4
|
+
interface ICity {
|
|
5
|
+
id: ID!
|
|
6
|
+
name: String!
|
|
7
|
+
state: ITerritorialState!
|
|
8
|
+
location: GeoLocation
|
|
9
|
+
createdAt: DateTime!
|
|
10
|
+
updatedAt: DateTime!
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
Address City Create Input
|
|
15
|
+
"""
|
|
16
|
+
input CityInput {
|
|
17
|
+
"""
|
|
18
|
+
Name of the state to display
|
|
19
|
+
"""
|
|
20
|
+
name: String!
|
|
21
|
+
"""
|
|
22
|
+
ID of State to associate
|
|
23
|
+
"""
|
|
24
|
+
state: TerritorialStateInput!
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
Address City Update Input
|
|
29
|
+
"""
|
|
30
|
+
input CityUpdateInput {
|
|
31
|
+
name: String
|
|
32
|
+
state: TerritorialStateUpdateInput!
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
"""
|
|
36
|
+
Pub N Go Property Address City
|
|
37
|
+
"""
|
|
38
|
+
type City implements ICity {
|
|
39
|
+
id: ID!
|
|
40
|
+
name: String!
|
|
41
|
+
state: State!
|
|
42
|
+
location: GeoLocation
|
|
43
|
+
createdAt: DateTime!
|
|
44
|
+
updatedAt: DateTime!
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type Cities {
|
|
48
|
+
totalCount: Int!
|
|
49
|
+
data: [City]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
input CitiesOptions {
|
|
53
|
+
criteria: AnyObject
|
|
54
|
+
limit: Int
|
|
55
|
+
skip: Int
|
|
56
|
+
sort: Sort
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
input CitiesInput {
|
|
60
|
+
countryOptions: CitiesOptions
|
|
61
|
+
stateOptions: CitiesOptions
|
|
62
|
+
cityOptions: CitiesOptions
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
extend type Query {
|
|
66
|
+
cities(input: CitiesInput): Cities!
|
|
67
|
+
city(id: ID!): City!
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
extend type Mutation {
|
|
71
|
+
createCity(propertyCity: CityInput!): City!
|
|
72
|
+
updateCity(id: ID!, propertyCity: CityUpdateInput!): City!
|
|
73
|
+
deleteCity(id: ID!): Boolean!
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface ICountry {
|
|
77
|
+
id: ID!
|
|
78
|
+
name: String!
|
|
79
|
+
phone_code: String!
|
|
80
|
+
currency: String
|
|
81
|
+
currency_symbol: String
|
|
82
|
+
emoji: String
|
|
83
|
+
location: GeoLocation
|
|
84
|
+
createdAt: DateTime!
|
|
85
|
+
updatedAt: DateTime!
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
type Country implements ICountry {
|
|
89
|
+
id: ID!
|
|
90
|
+
name: String!
|
|
91
|
+
phone_code: String!
|
|
92
|
+
currency: String
|
|
93
|
+
currency_symbol: String
|
|
94
|
+
emoji: String
|
|
95
|
+
location: GeoLocation
|
|
96
|
+
states(criteria: AnyObject, limit: Int, skip: Int, sort: Sort): States
|
|
97
|
+
createdAt: DateTime!
|
|
98
|
+
updatedAt: DateTime!
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
input CountryInput {
|
|
102
|
+
name: String!
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
type Countries {
|
|
106
|
+
totalCount: Int!
|
|
107
|
+
data: [Country]
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
extend type Query {
|
|
111
|
+
countries(criteria: AnyObject, limit: Int, skip: Int, sort: Sort): Countries!
|
|
112
|
+
country(id: ID!): Country!
|
|
113
|
+
countryByName(name: String!): Country!
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
extend type Mutation {
|
|
117
|
+
createCountry(country: CountryInput!): Country!
|
|
118
|
+
updateCountry(id: ID!, country: CountryInput!): Country!
|
|
119
|
+
deleteCountry(id: ID!): Boolean!
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type Country implements ICountry{
|
|
123
|
+
id: ID!
|
|
124
|
+
name: String!
|
|
125
|
+
phone_code: String!
|
|
126
|
+
currency: String
|
|
127
|
+
currency_symbol: String
|
|
128
|
+
emoji: String
|
|
129
|
+
location: GeoLocation
|
|
130
|
+
states(criteria: AnyObject, limit: Int, skip: Int, sort: Sort): States
|
|
131
|
+
createdAt: DateTime!
|
|
132
|
+
updatedAt: DateTime!
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type Countries {
|
|
136
|
+
totalCount: Int!
|
|
137
|
+
data: [Country]
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
extend type Query {
|
|
141
|
+
countries(criteria: AnyObject, limit: Int, skip: Int, sort: Sort): Countries!
|
|
142
|
+
country(id: ID!): Country!
|
|
143
|
+
countryByName(name: String!): Country!
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
extend type Mutation {
|
|
147
|
+
createCountry(country: CountryInput!): Country!
|
|
148
|
+
updateCountry(id: ID!, country: CountryInput!): Country!
|
|
149
|
+
deleteCountry(id: ID!): Boolean!
|
|
150
|
+
}
|
|
151
|
+
"""
|
|
152
|
+
Territorial State
|
|
153
|
+
"""
|
|
154
|
+
interface ITerritorialState {
|
|
155
|
+
id: ID!
|
|
156
|
+
name: String!
|
|
157
|
+
country: ICountry!
|
|
158
|
+
location: GeoLocation
|
|
159
|
+
createdAt: DateTime!
|
|
160
|
+
updatedAt: DateTime!
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
"""
|
|
164
|
+
Address State Create Input
|
|
165
|
+
"""
|
|
166
|
+
input TerritorialStateInput {
|
|
167
|
+
"""
|
|
168
|
+
Name of the country to display
|
|
169
|
+
"""
|
|
170
|
+
name: String!
|
|
171
|
+
"""
|
|
172
|
+
ID of Country to associate
|
|
173
|
+
"""
|
|
174
|
+
country: String!
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
"""
|
|
178
|
+
Address State Update Input
|
|
179
|
+
"""
|
|
180
|
+
input TerritorialStateUpdateInput {
|
|
181
|
+
name: String
|
|
182
|
+
country: Int!
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
"""
|
|
187
|
+
Address State
|
|
188
|
+
"""
|
|
189
|
+
type State implements ITerritorialState{
|
|
190
|
+
id: ID!
|
|
191
|
+
name: String!
|
|
192
|
+
country: Country!
|
|
193
|
+
cities(criteria: AnyObject, limit: Int, skip: Int, sort: Sort): Cities!
|
|
194
|
+
location: GeoLocation
|
|
195
|
+
createdAt: DateTime!
|
|
196
|
+
updatedAt: DateTime!
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
"""
|
|
200
|
+
Address State Create Input
|
|
201
|
+
"""
|
|
202
|
+
input StateInput {
|
|
203
|
+
"""
|
|
204
|
+
Name of the country to display
|
|
205
|
+
"""
|
|
206
|
+
name: String!
|
|
207
|
+
"""
|
|
208
|
+
ID of Country to associate
|
|
209
|
+
"""
|
|
210
|
+
country: String!
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
"""
|
|
214
|
+
Address State Update Input
|
|
215
|
+
"""
|
|
216
|
+
input StateUpdateInput {
|
|
217
|
+
name: String
|
|
218
|
+
country: String!
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
type States {
|
|
222
|
+
totalCount: Int!
|
|
223
|
+
data: [State]
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
extend type Query {
|
|
227
|
+
states(criteria: AnyObject, limit: Int, skip: Int, sort: Sort): States!
|
|
228
|
+
state(id: ID!): State!
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
extend type Mutation {
|
|
232
|
+
createState(state: StateInput!): State!
|
|
233
|
+
updateState(id: ID!, state: StateUpdateInput!): State!
|
|
234
|
+
deleteState(id: ID!): Boolean!
|
|
235
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testMatch: [
|
|
3
|
+
'<rootDir>/modules/**/server-ts/**/*.test.[jt]s?(x)',
|
|
4
|
+
'<rootDir>/modules/**/common-react/**/*.test.[jt]s?(x)',
|
|
5
|
+
],
|
|
6
|
+
globalSetup: '<rootDir>/packages/server/src/__tests__/jestSetup.js',
|
|
7
|
+
rootDir: '../..',
|
|
8
|
+
resolver: './packages/server/jest.resolver',
|
|
9
|
+
transform: {
|
|
10
|
+
'\\.(gql|graphql)$': 'jest-transform-graphql',
|
|
11
|
+
'locales[\\/]index.[jt]s': '<rootDir>/jest-transform-i18next',
|
|
12
|
+
'.*': 'babel-jest',
|
|
13
|
+
},
|
|
14
|
+
moduleNameMapper: {
|
|
15
|
+
'^.+\\.(css|less|scss)$': 'babel-jest',
|
|
16
|
+
},
|
|
17
|
+
globals: {
|
|
18
|
+
__CLIENT__: false,
|
|
19
|
+
__SERVER__: true,
|
|
20
|
+
__DEV__: true,
|
|
21
|
+
__TEST__: true,
|
|
22
|
+
__SSR__: false,
|
|
23
|
+
__FRONTEND_BUILD_DIR__: `${__dirname}/../client/build`,
|
|
24
|
+
__API_URL__: '/graphql',
|
|
25
|
+
},
|
|
26
|
+
testEnvironment: 'node',
|
|
27
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Update with your config settings.
|
|
2
|
+
var path = require('path');
|
|
3
|
+
require('dotenv').config({ path: process.env.ENV_FILE });
|
|
4
|
+
|
|
5
|
+
var connection = {
|
|
6
|
+
host: process.env.DB_HOST,
|
|
7
|
+
user: process.env.DB_USER,
|
|
8
|
+
socketPath: process.env.DB_SOCKET_PATH,
|
|
9
|
+
password: process.env.DB_PASSWORD,
|
|
10
|
+
database: process.env.DB_DATABASE,
|
|
11
|
+
multipleStatements: true,
|
|
12
|
+
charset: 'utf8',
|
|
13
|
+
};
|
|
14
|
+
var DB_CLIENT = process.env.DB_TYPE || 'sqlite3';
|
|
15
|
+
|
|
16
|
+
var migrations_path = path.dirname(require.resolve('@adminide-stack/store/lib/store/migrations/index'));
|
|
17
|
+
var seeds_path = path.dirname(require.resolve('@adminide-stack/store/lib/store/seeds/index'));
|
|
18
|
+
module.exports = {
|
|
19
|
+
|
|
20
|
+
development: {
|
|
21
|
+
client: 'sqlite3',
|
|
22
|
+
connection: {
|
|
23
|
+
filename: './dev-db.sqlite3'
|
|
24
|
+
},
|
|
25
|
+
seeds: {
|
|
26
|
+
directory: seeds_path,
|
|
27
|
+
},
|
|
28
|
+
migrations: {
|
|
29
|
+
directory: migrations_path,
|
|
30
|
+
},
|
|
31
|
+
useNullAsDefault: true,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
test: {
|
|
35
|
+
client: DB_CLIENT,
|
|
36
|
+
connection: connection,
|
|
37
|
+
pool: {
|
|
38
|
+
min: 2,
|
|
39
|
+
max: 10
|
|
40
|
+
},
|
|
41
|
+
seeds: {
|
|
42
|
+
directory: seeds_path,
|
|
43
|
+
},
|
|
44
|
+
migrations: {
|
|
45
|
+
directory: migrations_path,
|
|
46
|
+
},
|
|
47
|
+
useNullAsDefault: true,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
production: {
|
|
51
|
+
client: DB_CLIENT,
|
|
52
|
+
connection: connection,
|
|
53
|
+
pool: {
|
|
54
|
+
min: 2,
|
|
55
|
+
max: 200
|
|
56
|
+
},
|
|
57
|
+
migrations: {
|
|
58
|
+
directory: migrations_path,
|
|
59
|
+
},
|
|
60
|
+
useNullAsDefault: true,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
};
|