-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
AddLocation.js
29 lines (26 loc) · 1011 Bytes
/
AddLocation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// @flow strict-local
import { GraphQLNonNull } from 'graphql';
import AddLocationInput from '../types/input/AddLocationInput';
import AddLocationOrError, { ValidLocationResponse } from '../types/output/AddLocationOrError';
import type { LocationInput } from '../locations';
type Args = {
+location: LocationInput,
...
};
export default {
type: AddLocationOrError,
description: 'Add a new location',
args: {
/* $FlowFixMe[value-as-type] This comment suppresses an error when
* upgrading Flow to version 0.164.0. To see the error delete this comment
* and run Flow. */
location: { type: (GraphQLNonNull(AddLocationInput): GraphQLNonNull<typeof AddLocationInput>) },
},
resolve: (_: mixed, { location }: Args): ValidLocationResponse | string => {
if (location.name === '' || location.locationId.length !== 3) {
// TODO: ErrorClass and handle missing type, possibly locationId.length !== 3
return '';
}
return new ValidLocationResponse(location);
},
};