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
aa08fdf0
Commit
aa08fdf0
authored
Mar 23, 2020
by
Simon Knox
Committed by
Kushal Pandya
Mar 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs for manual apollo queries
For those times when you don't want to auto-fetcn on mount
parent
135011c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
5 deletions
+41
-5
doc/development/fe_guide/graphql.md
doc/development/fe_guide/graphql.md
+41
-5
No files found.
doc/development/fe_guide/graphql.md
View file @
aa08fdf0
...
...
@@ -35,9 +35,9 @@ of the client doing compilation of queries.
To distinguish queries from mutations and fragments, the following naming convention is recommended:
-
`all
U
sers.query.graphql`
for queries;
-
`add
U
ser.mutation.graphql`
for mutations;
-
`basic
U
ser.fragment.graphql`
for fragments.
-
`all
_u
sers.query.graphql`
for queries;
-
`add
_u
ser.mutation.graphql`
for mutations;
-
`basic
_u
ser.fragment.graphql`
for fragments.
### Fragments
...
...
@@ -56,8 +56,8 @@ fragment DesignListItem on Design {
Fragments can be stored in separate files, imported and used in queries, mutations, or other fragments.
```
javascript
#
import
"
./design
L
ist.fragment.graphql
"
#
import
"
./diff
R
efs.fragment.graphql
"
#
import
"
./design
_l
ist.fragment.graphql
"
#
import
"
./diff
_r
efs.fragment.graphql
"
fragment
DesignItem
on
Design
{
...
DesignListItem
...
...
@@ -258,6 +258,42 @@ export default {
};
```
### Manually triggering queries
Queries on a component's
`apollo`
property are made automatically when the component is created.
Some components instead want the network request made on-demand, for example a dropdown with lazy-loaded items.
There are two ways to do this:
1.
Use the
`skip`
property
```
javascript
export
default
{
apollo
:
{
user
:
{
query
:
QUERY_IMPORT
,
skip
()
{
// only make the query when dropdown is open
return
!
this
.
isOpen
;
},
}
},
};
```
1.
Using
`addSmartQuery`
You can manually create the Smart Query in your method.
```
javascript
handleClick
()
{
this
.
$apollo
.
addSmartQuery
(
'
user
'
,
{
// this takes the same values as you'd have in the `apollo` section
query
:
QUERY_IMPORT
,
}),
};
```
### Working with pagination
GitLab's GraphQL API uses
[
Relay-style cursor pagination
](
https://www.apollographql.com/docs/react/data/pagination/#cursor-based
)
...
...
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