Skip to content

Commit

Permalink
fix: throw error on missing required query argument (#836)
Browse files Browse the repository at this point in the history
* fix: throw error on missing required query argument

* Fixes

* fix

* Unwanted import

---------

Co-authored-by: ChaituVR <[email protected]>
  • Loading branch information
wa0x6e and ChaituVR authored Apr 9, 2024
1 parent 85e11c6 commit fb4c253
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/graphql/operations/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import log from '../../helpers/log';

export default async function (parent, args) {
const { where = {} } = args;

const { address } = where;
if (!address) return Promise.reject(new Error('address is required'));

const query = `
SELECT * FROM spaces
Expand Down
1 change: 0 additions & 1 deletion src/graphql/operations/space.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import log from '../../helpers/log';
import { capture } from '@snapshot-labs/snapshot-sentry';

export default async function (_parent, { id }, context, info) {
if (!id) return new PublicError('Missing id');
try {
let spaces = await fetchSpaces({ first: 1, where: { id } });
if (spaces.length !== 1) return null;
Expand Down
2 changes: 0 additions & 2 deletions src/graphql/operations/vote.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { capture } from '@snapshot-labs/snapshot-sentry';
import { PublicError } from '../helpers';
import log from '../../helpers/log';
import fetchVotes from './votes';

export default async function (parent, { id }, context, info) {
if (!id) return new PublicError('Missing id');
try {
const votes = await fetchVotes(
parent,
Expand Down
16 changes: 8 additions & 8 deletions src/graphql/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ scalar Any
# Queries

type Query {
space(id: String): Space
space(id: String!): Space

spaces(
first: Int! = 20
Expand All @@ -15,7 +15,7 @@ type Query {

ranking(first: Int! = 20, skip: Int! = 0, where: RankingWhere): RankingObject

proposal(id: String): Proposal
proposal(id: String!): Proposal

proposals(
first: Int! = 20
Expand All @@ -25,7 +25,7 @@ type Query {
orderDirection: OrderDirection
): [Proposal]

vote(id: String): Vote
vote(id: String!): Vote

votes(
first: Int! = 20
Expand All @@ -43,7 +43,7 @@ type Query {
orderDirection: OrderDirection
): [Alias]

roles(where: RolesWhere): [Role]
roles(where: RolesWhere!): [Role]

follows(
first: Int! = 20
Expand Down Expand Up @@ -77,9 +77,9 @@ type Query {
orderDirection: OrderDirection
): [Statement]

user(id: String): User
user(id: String!): User

statement(id: String): Statement
statement(id: String!): Statement

skins: [Item]

Expand All @@ -91,7 +91,7 @@ type Query {

strategies: [StrategyItem]

strategy(id: String): StrategyItem
strategy(id: String!): StrategyItem

vp(voter: String!, space: String!, proposal: String): Vp

Expand Down Expand Up @@ -264,7 +264,7 @@ input AliasWhere {
}

input RolesWhere {
address: String
address: String!
}

input FollowWhere {
Expand Down

0 comments on commit fb4c253

Please sign in to comment.