Skip to content

Commit

Permalink
chore: update persisted query not found error message (wundergraph#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aenimus authored Dec 14, 2024
1 parent c31c563 commit d5d118b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions router-tests/automatic_persisted_queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAutomaticPersistedQueries(t *testing.T) {
res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "does-not-exist"}}`),
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
})
})

Expand All @@ -57,7 +57,7 @@ func TestAutomaticPersistedQueries(t *testing.T) {
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"}}`),
Header: header,
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)

res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `{__typename}`,
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestAutomaticPersistedQueries(t *testing.T) {
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"}}`),
Header: header,
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
})
})

Expand Down Expand Up @@ -187,7 +187,7 @@ func TestAutomaticPersistedQueries(t *testing.T) {
res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "does-not-exist"}}`),
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
})
})

Expand Down Expand Up @@ -222,7 +222,7 @@ func TestAutomaticPersistedQueries(t *testing.T) {
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"}}`),
Header: header,
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)

res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Query: `{__typename}`,
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestAutomaticPersistedQueries(t *testing.T) {
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"}}`),
Header: header,
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
})
})

Expand Down
6 changes: 3 additions & 3 deletions router-tests/persisted_operations_over_get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestPersistedOperationOverGET(t *testing.T) {
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
})
})

Expand Down Expand Up @@ -104,7 +104,7 @@ func TestAutomatedPersistedQueriesOverGET(t *testing.T) {
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
})
})

Expand All @@ -128,7 +128,7 @@ func TestAutomatedPersistedQueriesOverGET(t *testing.T) {
})
require.NoError(t, err0)
require.Equal(t, http.StatusOK, res0.Response.StatusCode)
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res0.Body)

res1, err1 := xEnv.MakeGraphQLRequestOverGET(testenv.GraphQLRequest{
Query: `{__typename}`,
Expand Down
4 changes: 2 additions & 2 deletions router-tests/persisted_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestPersistedOperationNotFound(t *testing.T) {
res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Extensions: []byte(`{"persistedQuery": {"version": 1, "sha256Hash": "does-not-exist"}}`),
})
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
})
}

Expand Down Expand Up @@ -205,7 +205,7 @@ func TestPersistedOperationsCache(t *testing.T) {
Variables: []byte(`{"withAligators": false,"withCats": true,"skipDogs": false,"skipMouses": true}`),
})
require.NoError(t, err)
require.Equal(t, `{"errors":[{"message":"persisted query not found","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, `{"errors":[{"message":"PersistedQueryNotFound","extensions":{"code":"PERSISTED_QUERY_NOT_FOUND"}}]}`, res.Body)
require.Equal(t, "", res.Response.Header.Get(core.PersistedOperationCacheHeader))
require.Equal(t, "", res.Response.Header.Get(core.ExecutionPlanCacheHeader))
}
Expand Down
2 changes: 1 addition & 1 deletion router/core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func writeOperationError(r *http.Request, w http.ResponseWriter, requestLogger *
case errors.As(err, &httpErr):
writeRequestErrors(r, w, httpErr.StatusCode(), requestErrorsFromHttpError(httpErr), requestLogger)
case errors.As(err, &poNotFoundErr):
newErr := NewHttpGraphqlError("persisted query not found", "PERSISTED_QUERY_NOT_FOUND", http.StatusOK)
newErr := NewHttpGraphqlError("PersistedQueryNotFound", "PERSISTED_QUERY_NOT_FOUND", http.StatusOK)
writeRequestErrors(r, w, http.StatusOK, requestErrorsFromHttpError(newErr), requestLogger)
case errors.As(err, &reportErr):
report := reportErr.Report()
Expand Down

0 comments on commit d5d118b

Please sign in to comment.