Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump graphql from 15.6.1 to 16.0.1 #2008

Merged
merged 2 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions web/src/app/util/errutil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'lodash'
import { ApolloError } from '@apollo/client'
import { GraphQLError } from 'graphql/error'

const mapName = (name: string): string => _.camelCase(name).replace(/Id$/, 'ID')

Expand Down Expand Up @@ -35,7 +36,7 @@ export function nonFieldErrors(err?: ApolloError): Error[] {
export interface FieldError extends Error {
field: string
details: { [x: string]: string }
path: string[]
path: GraphQLError['path']
}

function isFieldError(e: Error | FieldError): e is FieldError {
Expand All @@ -60,23 +61,28 @@ export function fieldErrors(err?: ApolloError): FieldError[] {
)
.map((err) => {
if (err.extensions?.isMultiFieldError) {
return err.extensions.fieldErrors.map((e: RawFieldError) => ({
return (err.extensions.fieldErrors as RawFieldError[]).map((e) => ({
field: e.fieldName.split('.').map(mapName).join('.'),
message: stripMessage(e.message),
details: parseDetails(e.message),
path: err.path,
name: 'FieldError',
}))
}

return {
field: err.extensions?.fieldName.split('.').map(mapName).join('.'),
field: (err.extensions?.fieldName as string)
.split('.')
.map(mapName)
.join('.'),
message: stripMessage(err.message),
details: parseDetails(err.message),
path: err.path,
name: 'FieldError',
}
})

return [].concat(...errs)
return errs.flat()
}

// allErrors will return a flat list of all errors in the graphQL error.
Expand All @@ -88,6 +94,6 @@ export function allErrors(err?: ApolloError): Error[] {
// byPath will group errors by their path name.
export function errorsByPath(err: ApolloError): { [x: string]: Error[] } {
return _.groupBy(allErrors(err), (e: Error | FieldError) =>
(isFieldError(e) ? e.path : []).join('.'),
(isFieldError(e) && e.path ? e.path : []).join('.'),
)
}
2 changes: 1 addition & 1 deletion web/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"classnames": "2.3.1",
"connected-react-router": "6.9.1",
"diff": "5.0.0",
"graphql": "15.6.1",
"graphql": "16.0.1",
"history": "4.10.1",
"lodash": "4.17.21",
"luxon": "1.28.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4775,10 +4775,10 @@ graphql-tag@^2.12.0:
dependencies:
tslib "^2.1.0"

graphql@15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.6.1.tgz#9125bdf057553525da251e19e96dab3d3855ddfc"
integrity sha512-3i5lu0z6dRvJ48QP9kFxBkJ7h4Kso7PS8eahyTFz5Jm6CvQfLtNIE8LX9N6JLnXTuwR+sIYnXzaWp6anOg0QQw==
graphql@16.0.1:
version "16.0.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.0.1.tgz#93a13cd4e0e38ca8d0832e79614c8578bfd34f10"
integrity sha512-oPvCuu6dlLdiz8gZupJ47o1clgb72r1u8NDBcQYjcV6G/iEdmE11B1bBlkhXRvV0LisP/SXRFP7tT6AgaTjpzg==

handle-thing@^2.0.0:
version "2.0.1"
Expand Down