Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8280b77a
Commit
8280b77a
authored
Jun 07, 2021
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix States GQL local resolver
parent
59d02126
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
ee/app/assets/javascripts/subscriptions/buy_minutes/graphql/resolvers.js
...avascripts/subscriptions/buy_minutes/graphql/resolvers.js
+6
-3
ee/app/assets/javascripts/subscriptions/graphql/queries/states.query.graphql
...cripts/subscriptions/graphql/queries/states.query.graphql
+6
-0
ee/spec/frontend/subscriptions/buy_minutes/graphql/resolvers_spec.js
...ntend/subscriptions/buy_minutes/graphql/resolvers_spec.js
+4
-4
No files found.
ee/app/assets/javascripts/subscriptions/buy_minutes/graphql/resolvers.js
View file @
8280b77a
...
...
@@ -2,7 +2,10 @@ import { produce } from 'immer';
import
{
merge
}
from
'
lodash
'
;
import
Api
from
'
ee/api
'
;
import
*
as
SubscriptionsApi
from
'
ee/api/subscriptions_api
'
;
import
{
ERROR_FETCHING_COUNTRIES
,
ERROR_FETCHING_STATES
}
from
'
ee/subscriptions/constants
'
;
import
{
ERROR_FETCHING_COUNTRIES
,
ERROR_FETCHING_STATES
,
}
from
'
ee/subscriptions/constants
'
;
import
STATE_QUERY
from
'
ee/subscriptions/graphql/queries/state.query.graphql
'
;
import
createFlash
from
'
~/flash
'
;
...
...
@@ -20,11 +23,11 @@ export const resolvers = {
)
.
catch
(()
=>
createFlash
({
message
:
ERROR_FETCHING_COUNTRIES
}));
},
states
:
(
countryId
)
=>
{
states
:
(
_
,
{
countryId
}
)
=>
{
return
Api
.
fetchStates
(
countryId
)
.
then
(({
data
})
=>
{
// eslint-disable-next-line @gitlab/require-i18n-strings
return
data
.
map
((
state
)
=>
Object
.
assign
(
state
,
{
__typename
:
'
State
'
}));
return
Object
.
entries
(
data
).
map
(([
key
,
value
])
=>
({
id
:
value
,
name
:
key
,
__typename
:
'
State
'
}));
})
.
catch
(()
=>
createFlash
({
message
:
ERROR_FETCHING_STATES
}));
},
...
...
ee/app/assets/javascripts/subscriptions/graphql/queries/states.query.graphql
0 → 100644
View file @
8280b77a
query
State
(
$countryId
:
ID
!)
{
states
(
countryId
:
$countryId
)
@client
{
id
name
}
}
ee/spec/frontend/subscriptions/buy_minutes/graphql/resolvers_spec.js
View file @
8280b77a
...
...
@@ -47,7 +47,7 @@ const countries = [
[
'
Uruguay
'
,
'
UY
'
],
];
const
states
=
[{
id
:
1
,
name
:
'
state
'
}]
;
const
states
=
{
'
California
'
:
'
CA
'
}
;
describe
(
'
~/subscriptions/buy_minutes/graphql/resolvers
'
,
()
=>
{
describe
(
'
Query
'
,
()
=>
{
...
...
@@ -88,10 +88,10 @@ describe('~/subscriptions/buy_minutes/graphql/resolvers', () => {
});
it
(
'
returns an array of states with typename
'
,
async
()
=>
{
const
result
=
await
resolvers
.
Query
.
states
(
1
);
const
result
=
await
resolvers
.
Query
.
states
(
null
,
{
countryId
:
1
}
);
expect
(
createFlash
).
not
.
toHaveBeenCalled
();
expect
(
result
).
toStrictEqual
([{
id
:
1
,
name
:
'
state
'
,
__typename
:
'
State
'
}]);
expect
(
result
).
toStrictEqual
([{
id
:
'
CA
'
,
name
:
'
California
'
,
__typename
:
'
State
'
}]);
});
});
...
...
@@ -101,7 +101,7 @@ describe('~/subscriptions/buy_minutes/graphql/resolvers', () => {
});
it
(
'
shows a flash message
'
,
async
()
=>
{
await
resolvers
.
Query
.
states
();
await
resolvers
.
Query
.
states
(
null
,
{
countryId
:
1
}
);
expect
(
createFlash
).
toHaveBeenCalledWith
({
message
:
ERROR_FETCHING_STATES
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment