Skip to content

Commit

Permalink
feat(@whook/example): add GraphQL server
Browse files Browse the repository at this point in the history
  • Loading branch information
nfroidure committed Aug 20, 2023
1 parent 473cc54 commit 1b042d1
Show file tree
Hide file tree
Showing 15 changed files with 2,230 additions and 4,170 deletions.
6,047 changes: 1,881 additions & 4,166 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,16 @@ DEV_MODE=1
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down Expand Up @@ -477,13 +480,16 @@ DEV_MODE=1
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down Expand Up @@ -849,13 +855,16 @@ DEV_MODE=1
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down Expand Up @@ -1204,13 +1213,16 @@ DEV_MODE=1
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down
9 changes: 9 additions & 0 deletions packages/whook-create/src/services/createWhook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,16 @@ describe('initCreateWhook', () => {
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down Expand Up @@ -382,13 +385,16 @@ describe('initCreateWhook', () => {
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down Expand Up @@ -589,13 +595,16 @@ describe('initCreateWhook', () => {
"dependencies": {
"@whook/authorization": "<current_version>",
"@whook/cors": "<current_version>",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "<current_version>",
"@whook/http-server": "<current_version>",
"@whook/http-transaction": "<current_version>",
"@whook/swagger-ui": "<current_version>",
"@whook/whook": "<current_version>",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/whook-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,16 @@
"dependencies": {
"@whook/authorization": "^13.1.0",
"@whook/cors": "^13.1.0",
"@whook/graphiql": "^13.1.0",
"@whook/graphql": "^13.1.0",
"@whook/http-router": "^13.1.0",
"@whook/http-server": "^13.1.0",
"@whook/http-transaction": "^13.1.0",
"@whook/swagger-ui": "^13.1.0",
"@whook/whook": "^13.1.0",
"application-services": "^4.0.0",
"common-services": "^15.0.0",
"graphql-tag": "^2.12.6",
"http-auth-utils": "^5.0.1",
"jwt-service": "^10.0.4",
"knifecycle": "^17.0.1",
Expand Down
3 changes: 3 additions & 0 deletions packages/whook-example/src/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ exports[`commands should work with ls 1`] = `
- printEnv: A command printing every env values
# Provided by "@whook/graphql": none
# Provided by "@whook/whook": 8 commands
- config: A simple program that returns the queryed config value
- create: A command helping to create new Whook files easily
Expand Down
4 changes: 4 additions & 0 deletions packages/whook-example/src/config/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const CONFIG: Omit<AppConfig, 'HOST'> = {
'User-Agent',
].join(','),
},
GRAPHIQL: {
path: '/graphiql',
defaultQuery: '{ hello }',
},
};

export default CONFIG;
1 change: 1 addition & 0 deletions packages/whook-example/src/config/local/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Finally the configuration file for a given environnment
const CONFIG: AppConfig = {
...COMMON_CONFIG,
HOST: 'localhost',
DEV_ACCESS_MECHANISM: 'Fake',
DEV_ACCESS_TOKEN: 'admin|1|1',
DEFAULT_MECHANISM: 'Fake',
// This allows you to map service names depending on
Expand Down
22 changes: 22 additions & 0 deletions packages/whook-example/src/handlers/getGraphQL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Disabled since it leads to crypty import errors
// import {
// initGetGraphQL,
// getGraphQLDefinition as baseDefinition,
// } from '@whook/graphql';
// import type { WhookAPIHandlerDefinition } from '@whook/whook';

// // Add authentication to the base getGraphQL endpoints that
// // would otherwise be public per default
// export const definition: WhookAPIHandlerDefinition = {
// ...baseDefinition,
// operation: {
// ...baseDefinition.operation,
// security: [
// {
// bearerAuth: ['admin'],
// },
// ],
// },
// };

// export default initGetGraphQL;
21 changes: 21 additions & 0 deletions packages/whook-example/src/handlers/postGraphQL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
initPostGraphQL,
postGraphQLDefinition as baseDefinition,
} from '@whook/graphql';
import type { WhookAPIHandlerDefinition } from '@whook/whook';

// Add authentication to the base postGraphQL endpoints that
// would otherwise be public per default
export const definition: WhookAPIHandlerDefinition = {
...baseDefinition,
operation: {
...baseDefinition.operation,
security: [
{
bearerAuth: ['admin'],
},
],
},
};

export default initPostGraphQL;
Loading

0 comments on commit 1b042d1

Please sign in to comment.