Skip to content

Commit

Permalink
initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
gilgardosh committed Apr 18, 2024
1 parent e807624 commit 8a89a6c
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 35 deletions.
114 changes: 114 additions & 0 deletions packages/green-invoice-graphql/mesh.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import { OperationTypeNode } from 'graphql';
import { defineConfig } from '@graphql-mesh/compose-cli';
import { loadJSONSchemaSubgraph } from '@omnigraph/json-schema';

export const composeConfig = defineConfig({
subgraphs: [
{
sourceHandler: loadJSONSchemaSubgraph('GreenInvoice', {
operationHeaders: {
Authorization: 'Bearer {context.authToken}',
'Content-Type': 'application/json',
},
endpoint: 'https://api.greeninvoice.co.il/api/v1',
operations: [
{
type: OperationTypeNode.MUTATION,
field: 'addExpense',
path: '/expenses',
method: 'POST',
requestSchema: '../json-schemas/greenInvoice.json#/definitions/addExpenseRequest',
responseSchema: '../json-schemas/greenInvoice.json#/definitions/addExpenseResponse',
responseSample: 'https://www.reddit.com/r/AskReddit.json',
},
{
type: OperationTypeNode.QUERY,
field: 'getExpense',
path: '/expenses/{args.id}',
method: 'GET',
argTypeMap: {
id: {
type: 'string',
nullable: false,
},
},
responseSchema: '../json-schemas/greenInvoice.json#/definitions/getExpenseResponse',
},
{
type: OperationTypeNode.MUTATION,
field: 'updateExpense',
path: '/expenses/{args.id}',
method: 'PUT',
requestSchema: '../json-schemas/greenInvoice.json#/definitions/updateExpenseRequest',
responseSchema: '../json-schemas/greenInvoice.json#/definitions/updateExpenseResponse',
},
{
type: OperationTypeNode.QUERY,
field: 'searchExpenses',
path: '/expenses/search',
method: 'POST',
requestSchema: '../json-schemas/greenInvoice.json#/definitions/searchExpensesRequest',
responseSchema: '../json-schemas/greenInvoice.json#/definitions/searchExpensesResponse',
},
{
type: OperationTypeNode.QUERY,
field: 'searchDocuments',
path: '/documents/search',
method: 'POST',
requestSchema: '../json-schemas/greenInvoice.json#/definitions/searchDocumentsRequest',
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/searchDocumentsResponse',
},
{
type: OperationTypeNode.MUTATION,
field: 'addExpenseDraftByFile',
path: '/expenses/file',
method: 'POST',
requestSchema:
'../json-schemas/greenInvoice.json#/definitions/addExpenseDraftByFileRequest',
responseByStatusCode: {
200: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/addExpenseDraftByFileResponse',
},
201: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/addExpenseDraftByFileResponse',
},
400: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/generalErrorResponse',
},
404: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/generalErrorResponse',
},
},
},
{
type: OperationTypeNode.QUERY,
field: 'searchExpenseDrafts',
path: '/expenses/drafts/search',
method: 'POST',
requestSchema:
'../json-schemas/greenInvoice.json#/definitions/searchExpenseDraftsRequest',
responseByStatusCode: {
200: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/searchExpenseDraftsResponse',
},
201: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/searchExpenseDraftsResponse',
},
404: {
responseSchema:
'../json-schemas/greenInvoice.json#/definitions/generalErrorResponse',
},
},
},
],
}),
},
],
});
2 changes: 2 additions & 0 deletions packages/green-invoice-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"test": "node --import ../../scripts/register-esm.js ./dist/esm/dev-tests/e2e.js"
},
"dependencies": {
"@graphql-mesh/compose-cli": "0.2.5",
"@graphql-mesh/config": "0.99.9",
"@graphql-mesh/cross-helpers": "0.4.1",
"@graphql-mesh/http": "0.98.8",
Expand All @@ -64,6 +65,7 @@
"@graphql-mesh/store": "0.97.5",
"@graphql-mesh/types": "0.97.5",
"@graphql-mesh/utils": "0.97.5",
"@omnigraph/json-schema": "0.99.6",
"graphql": "16.8.1",
"path": "0.12.7"
},
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
"@accounter/pcn874-generator": ["packages/pcn874-generator/src/"]
}
},
"ts-node": {
"esm": true
},
"exclude": ["**/node_modules", "**/dist"]
}
Loading

0 comments on commit 8a89a6c

Please sign in to comment.