2020-10-13 11:33:11 +03:00
|
|
|
- description: query the remote with a non-existing input argument 'foo'
|
|
|
|
url: /v1/graphql
|
|
|
|
status: 200
|
|
|
|
query:
|
|
|
|
query: |
|
|
|
|
{
|
|
|
|
user(foo:1) {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response:
|
|
|
|
errors:
|
|
|
|
- extensions:
|
|
|
|
path: $.selectionSet.user
|
|
|
|
code: validation-failed
|
An `ErrorMessage` type, to encapsulate.
This introduces an `ErrorMessage` newtype which wraps `Text` in a manner which is designed to be easy to construct, and difficult to deconstruct.
It provides functionality similar to `Data.Text.Extended`, but designed _only_ for error messages. Error messages are constructed through `fromString`, concatenation, or the `toErrorValue` function, which is designed to be overridden for all meaningful domain types that might show up in an error message. Notably, there are not and should never be instances of `ToErrorValue` for `String`, `Text`, `Int`, etc. This is so that we correctly represent the value in a way that is specific to its type. For example, all `Name` values (from the _graphql-parser-hs_ library) are single-quoted now; no exceptions.
I have mostly had to add `instance ToErrorValue` for various backend types (and also add newtypes where necessary). Some of these are not strictly necessary for this changeset, as I had bigger aspirations when I started. These aspirations have been tempered by trying and failing twice.
As such, in this changeset, I have started by introducing this type to the `parseError` and `parseErrorWith` functions. In the future, I would like to extend this to the `QErr` record and the various `throwError` functions, but this is a much larger task and should probably be done in stages.
For now, `toErrorMessage` and `fromErrorMessage` are provided for conversion to and from `Text`, but the intent is to stop exporting these once all error messages are converted to the new type.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5018
GitOrigin-RevId: 84b37e238992e4312255a87ca44f41af65e2d89a
2022-07-18 23:26:01 +03:00
|
|
|
message: "'user' has no argument named 'foo'"
|
2020-10-13 11:33:11 +03:00
|
|
|
|
2021-05-24 23:12:53 +03:00
|
|
|
- description: query the remote with a string literal for an int
|
2020-10-13 11:33:11 +03:00
|
|
|
url: /v1/graphql
|
|
|
|
status: 200
|
|
|
|
query:
|
|
|
|
query: |
|
|
|
|
{
|
|
|
|
user(id:"1") {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response:
|
2021-05-24 23:12:53 +03:00
|
|
|
data:
|
2020-10-13 11:33:11 +03:00
|
|
|
errors:
|
2021-05-24 23:12:53 +03:00
|
|
|
- message: "Argument \"id\" has invalid value \"1\".\nExpected type \"Int\", found \"1\"."
|
|
|
|
locations:
|
|
|
|
- line: 1
|
|
|
|
column: 19
|
2020-10-13 11:33:11 +03:00
|
|
|
|
|
|
|
- description: query the remote with a non-existing input object field 'foo'
|
|
|
|
url: /v1/graphql
|
|
|
|
status: 200
|
|
|
|
query:
|
|
|
|
query: |
|
|
|
|
mutation {
|
|
|
|
createUserInputObj(userData:{id:5,username:"somethin",foo:"baz"}) {
|
|
|
|
user {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response:
|
|
|
|
errors:
|
|
|
|
- extensions:
|
|
|
|
path: $.selectionSet.createUserInputObj.args.userData.foo
|
|
|
|
code: validation-failed
|
An `ErrorMessage` type, to encapsulate.
This introduces an `ErrorMessage` newtype which wraps `Text` in a manner which is designed to be easy to construct, and difficult to deconstruct.
It provides functionality similar to `Data.Text.Extended`, but designed _only_ for error messages. Error messages are constructed through `fromString`, concatenation, or the `toErrorValue` function, which is designed to be overridden for all meaningful domain types that might show up in an error message. Notably, there are not and should never be instances of `ToErrorValue` for `String`, `Text`, `Int`, etc. This is so that we correctly represent the value in a way that is specific to its type. For example, all `Name` values (from the _graphql-parser-hs_ library) are single-quoted now; no exceptions.
I have mostly had to add `instance ToErrorValue` for various backend types (and also add newtypes where necessary). Some of these are not strictly necessary for this changeset, as I had bigger aspirations when I started. These aspirations have been tempered by trying and failing twice.
As such, in this changeset, I have started by introducing this type to the `parseError` and `parseErrorWith` functions. In the future, I would like to extend this to the `QErr` record and the various `throwError` functions, but this is a much larger task and should probably be done in stages.
For now, `toErrorMessage` and `fromErrorMessage` are provided for conversion to and from `Text`, but the intent is to stop exporting these once all error messages are converted to the new type.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5018
GitOrigin-RevId: 84b37e238992e4312255a87ca44f41af65e2d89a
2022-07-18 23:26:01 +03:00
|
|
|
message: "field 'foo' not found in type: 'UserDetailsInput'"
|
2021-03-15 09:30:53 +03:00
|
|
|
|
|
|
|
- description: an argument expecting a list of input objects should work properly
|
|
|
|
url: /v1/graphql
|
|
|
|
status: 200
|
|
|
|
query:
|
|
|
|
query: |
|
|
|
|
{
|
|
|
|
objectPassedToArrayType: user(id:1, userInfo: {id: 1, username: "foo"}) {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
user(id:1, userInfo: {id: 1, username: "foo"}) {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response:
|
|
|
|
data:
|
|
|
|
objectPassedToArrayType:
|
|
|
|
id: 1
|
|
|
|
username: jane
|
|
|
|
user:
|
|
|
|
id: 1
|
|
|
|
username: jane
|
|
|
|
|
|
|
|
- description: an argument expecting a list of input objects should work properly
|
|
|
|
url: /v1/graphql
|
|
|
|
status: 200
|
|
|
|
query:
|
|
|
|
query: |
|
|
|
|
{
|
|
|
|
objectPassedToArrayType: user(id:1, userInfo: {id: 1, username: "foo"}) {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
user(id:1, userInfo: [{id: 1, username: "foo"}]) {
|
|
|
|
id
|
|
|
|
username
|
|
|
|
}
|
|
|
|
}
|
|
|
|
response:
|
|
|
|
data:
|
|
|
|
objectPassedToArrayType:
|
|
|
|
id: 1
|
|
|
|
username: jane
|
|
|
|
user:
|
|
|
|
id: 1
|
|
|
|
username: jane
|