Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change v1 api (dashboard, graphiql) to v2 #257

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/api-gateways/api_gateway.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { bullBoardMixin } from '../../mixins/bullBoard/bullBoard.mixin';
path: '/api',
autoAliases: true, // allow generate rest info (GET/PUT/POST...) in the services
mappingPolicy: 'restrict', // allow action called with exact method
whitelist: ['v1.dashboard-statistics.*', 'v1.graphiql.*'],
whitelist: ['v2.dashboard-statistics.*', 'v2.graphql.*'],
},
],
// empty cors object will have moleculer to generate handler for preflight request and CORS header which allow all origin
Expand Down
4 changes: 2 additions & 2 deletions src/services/api-gateways/dashboard_statistics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import networks from '../../../network.json' assert { type: 'json' };

@Service({
name: 'dashboard-statistics',
version: 1,
version: 2,
})
export default class DashboardStatisticsService extends BaseService {
public constructor(public broker: ServiceBroker) {
Expand All @@ -35,7 +35,7 @@ export default class DashboardStatisticsService extends BaseService {
);

return this.broker.call(
`v1.dashboard-statistics.getDashboardStatistics@${selectedChain?.moleculerNamespace}`
`v2.dashboard-statistics.getDashboardStatistics@${selectedChain?.moleculerNamespace}`
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/services/api-gateways/graphiql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { ErrorCode, ErrorMessage } from '../../common/types/errors';
import Utils from '../../common/utils/utils';

@Service({
name: 'graphiql',
version: 1,
name: 'graphql',
version: 2,
settings: {
rateLimit: {
window: config.graphiqlApi.rateLimitWindow,
Expand Down
22 changes: 11 additions & 11 deletions test/unit/services/api-gateways/graphiql.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class GraphiQLTest {
// @Test('Query success')
// public async testQuerySuccess() {
// const result: ResponseDto = await this.broker.call(
// 'v1.graphiql.handleGraphQLQuery',
// 'v2.graphql.handleGraphQLQuery',
// {
// operationName: 'MyQuery',
// query:
Expand All @@ -43,7 +43,7 @@ export default class GraphiQLTest {
@Test('Invalid query format')
public async testInvalidQueryFormat() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query: 'abc',
Expand All @@ -59,7 +59,7 @@ export default class GraphiQLTest {
@Test('Invalid mutation operation')
public async testInvalidMutationOperation() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyMutation',
query:
Expand All @@ -78,7 +78,7 @@ export default class GraphiQLTest {
@Test('Query depth exceed limit')
public async testQueryDepthExceedLimit() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand All @@ -97,7 +97,7 @@ export default class GraphiQLTest {
@Test('Query root where depth exceed limit')
public async testQueryRootWhereDepthExceedLimit() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand All @@ -116,7 +116,7 @@ export default class GraphiQLTest {
@Test('Query sub where depth exceed limit')
public async testQuerySubWhereDepthExceedLimit() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand All @@ -135,7 +135,7 @@ export default class GraphiQLTest {
@Test('Query tables required where height failed - _eq case')
public async testQueryRequireWhereHeight_EqCase() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand All @@ -154,7 +154,7 @@ export default class GraphiQLTest {
@Test('Query tables required where height failed - _gt _lt case')
public async testQueryRequireWhereHeight_Gt_LtCase() {
let result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand All @@ -169,7 +169,7 @@ export default class GraphiQLTest {
`The query to one of the following tables needs to include exact height (_eq) or a height range (_gt/_gte & _lt/_lte) in where argument: ${config.graphiqlApi.queryNeedWhereModel}`
);

result = await this.broker.call('v1.graphiql.handleGraphQLQuery', {
result = await this.broker.call('v2.graphql.handleGraphQLQuery', {
operationName: 'MyQuery',
query:
'query MyQuery { auratestnet { event_attribute(where: { block_height: { _lte: 1 } }) { hash } } }',
Expand All @@ -186,7 +186,7 @@ export default class GraphiQLTest {
@Test('Query tables required where height failed - in where case')
public async testQueryRequireWhereHeightInWhereCase() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand All @@ -205,7 +205,7 @@ export default class GraphiQLTest {
@Test('Query tables required where height range exceed limit')
public async testQueryRequireWhereHeightRangeExceedLimit() {
const result: ResponseDto = await this.broker.call(
'v1.graphiql.handleGraphQLQuery',
'v2.graphql.handleGraphQLQuery',
{
operationName: 'MyQuery',
query:
Expand Down