Skip to content

Commit

Permalink
feat: add new options endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Oct 8, 2024
1 parent b25560c commit b1718db
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/graphql/operations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import follows from './follows';
import leaderboards from './leaderboards';
import messages from './messages';
import networks from './networks';
import options from './options';
import plugins from './plugins';
import proposal from './proposal';
import proposals from './proposals';
Expand Down Expand Up @@ -36,6 +37,7 @@ export default {
subscriptions,
skins,
networks,
options,
validations,
plugins,
strategies,
Expand Down
13 changes: 13 additions & 0 deletions src/graphql/operations/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { capture } from '@snapshot-labs/snapshot-sentry';
import log from '../../helpers/log';
import db from '../../helpers/mysql';

export default async function (_, args) {
try {
return await db.queryAsync('SELECT s.* FROM options s');
} catch (e: any) {
log.error(`[graphql] options, ${JSON.stringify(e)}`);
capture(e, { args });
return Promise.reject(new Error('request failed'));
}
}
7 changes: 7 additions & 0 deletions src/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ type Query {
orderBy: String
orderDirection: OrderDirection
): [Leaderboard]

options: [Option]
}

input SpaceWhere {
Expand Down Expand Up @@ -640,3 +642,8 @@ type Leaderboard {
votesCount: Int
lastVote: Int
}

type Option {
name: String
value: String
}
6 changes: 6 additions & 0 deletions src/helpers/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,9 @@ CREATE TABLE leaderboard (
INDEX proposal_count (proposal_count),
INDEX last_vote (last_vote)
);

CREATE TABLE options (
name VARCHAR(100) NOT NULL,
value VARCHAR(100) NOT NULL,
PRIMARY KEY (name)
);

0 comments on commit b1718db

Please sign in to comment.