diff --git a/graphql/errors.go b/graphql/errors.go index 6f3661f97a..70afd2d229 100644 --- a/graphql/errors.go +++ b/graphql/errors.go @@ -25,6 +25,7 @@ var ( errOnlyNumberOrHash = invalidParamsError("only one of number or hash must be specified") errBlockInvariant = invalidParamsError("block objects must be instantiated with at least one of num or hash") errInvalidBlockRange = invalidParamsError("invalid from and to block combination: from > to") + errFromBlockRequired = invalidParamsError("from block number must be specified") ) const ( diff --git a/graphql/graphql.go b/graphql/graphql.go index f0b2bfb634..e13fbba34b 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1320,7 +1320,7 @@ func (r *Resolver) Blocks(ctx context.Context, args struct { To *Long }) ([]*Block, error) { if args.From == nil { - return nil, errors.New("from block number must be specified") + return nil, errFromBlockRequired } from := rpc.BlockNumber(*args.From) diff --git a/graphql/graphql_test.go b/graphql/graphql_test.go index f760106d35..9580fa5db8 100644 --- a/graphql/graphql_test.go +++ b/graphql/graphql_test.go @@ -150,7 +150,7 @@ func TestGraphQLBlockSerialization(t *testing.T) { }, { body: `{"query": "{blocks {number}}"}`, - want: `{"errors":[{"message":"from block number must be specified","path":["blocks"]}],"data":null}`, + want: `{"errors":[{"message":"error [-32602]: from block number must be specified","path":["blocks"],"extensions":{"errorCode":-32602,"errorMessage":"from block number must be specified"}}],"data":null}`, code: 400, }, // invalid block range