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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
6ed496a8
Commit
6ed496a8
authored
Feb 22, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port design-management-vue-app to CE
parent
0152d6ff
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
10 deletions
+36
-10
app/assets/javascripts/issuable_suggestions/index.js
app/assets/javascripts/issuable_suggestions/index.js
+2
-2
app/assets/javascripts/lib/graphql.js
app/assets/javascripts/lib/graphql.js
+8
-6
doc/development/fe_guide/graphql.md
doc/development/fe_guide/graphql.md
+26
-2
No files found.
app/assets/javascripts/issuable_suggestions/index.js
View file @
6ed496a8
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
d
efaultClient
from
'
~/lib/graphql
'
;
import
createD
efaultClient
from
'
~/lib/graphql
'
;
import
App
from
'
./components/app.vue
'
;
Vue
.
use
(
VueApollo
);
...
...
@@ -10,7 +10,7 @@ export default function() {
const
issueTitle
=
document
.
getElementById
(
'
issue_title
'
);
const
{
projectPath
}
=
el
.
dataset
;
const
apolloProvider
=
new
VueApollo
({
defaultClient
,
defaultClient
:
createDefaultClient
()
,
});
return
new
Vue
({
...
...
app/assets/javascripts/lib/graphql.js
View file @
6ed496a8
import
ApolloClient
from
'
apollo-boost
'
;
import
csrf
from
'
~/lib/utils/csrf
'
;
export
default
new
ApolloClient
({
export
default
(
clientState
=
{})
=>
new
ApolloClient
({
uri
:
`
${
gon
.
relative_url_root
}
/api/graphql`
,
headers
:
{
[
csrf
.
headerKey
]:
csrf
.
token
,
},
});
clientState
,
});
doc/development/fe_guide/graphql.md
View file @
6ed496a8
...
...
@@ -27,11 +27,11 @@ the Vue application is mounted.
```
javascript
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
d
efaultClient
from
'
~/lib/graphql
'
;
import
createD
efaultClient
from
'
~/lib/graphql
'
;
Vue
.
use
(
VueApollo
);
const
apolloProvider
=
new
VueApollo
({
defaultClient
,
defaultClient
:
createDefaultClient
()
,
});
new
Vue
({
...
...
@@ -43,6 +43,29 @@ new Vue({
Read more about
[
Vue Apollo
][
vue-apollo
]
in the
[
Vue Apollo documentation
][
vue-apollo-docs
]
.
### Local state with `apollo-link-state`
It is possible to use our Apollo setup with
[
apollo-link-state
][
apollo-link-state
]
by passing
in the client state object when creating the default client.
```
javascript
import
Vue
from
'
vue
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
createDefaultClient
from
'
~/lib/graphql
'
;
Vue
.
use
(
VueApollo
);
const
apolloProvider
=
new
VueApollo
({
defaultClient
:
createDefaultClient
({
defaults
:
{
testing
:
true
,
},
resolvers
:
{
...
},
}),
});
```
### Testing
With
[
Vue test utils
][
vue-test-utils
]
it is easy to quickly test components that
...
...
@@ -81,3 +104,4 @@ Read more about the [Apollo] client in the [Apollo documentation][apollo-client-
[
default-client
]:
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/lib/graphql.js
[
apollo-client-docs
]:
https://www.apollographql.com/docs/tutorial/client.html
[
vue-test-utils
]:
https://vue-test-utils.vuejs.org/
[
apollo-link-state
]:
https://www.apollographql.com/docs/link/links/state.html
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