Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wotwizard-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emmanuel Salomon
wotwizard-ui
Commits
c44a2f42
Commit
c44a2f42
authored
3 years ago
by
Pierre-Jean CHANCELLIER
Browse files
Options
Downloads
Patches
Plain Diff
factorization of the graphQL layer for future alt servers
parent
e66ac8f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
graphql/cache.js
+21
-0
21 additions, 0 deletions
graphql/cache.js
graphql/endpoints.js
+3
-0
3 additions, 0 deletions
graphql/endpoints.js
graphql/index.js
+4
-25
4 additions, 25 deletions
graphql/index.js
graphql/schemaQuery.js
+2
-2
2 additions, 2 deletions
graphql/schemaQuery.js
with
30 additions
and
27 deletions
graphql/cache.js
0 → 100644
+
21
−
0
View file @
c44a2f42
import
{
InMemoryCache
,
IntrospectionFragmentMatcher
,
defaultDataIdFromObject
}
from
'
apollo-cache-inmemory
'
import
introspectionQueryResultData
from
'
./fragmentTypes.json
'
;
const
fragmentMatcher
=
new
IntrospectionFragmentMatcher
({
introspectionQueryResultData
})
// Apparemment il faut utiliser la syntaxe Apollo v2
export
const
cache
=
new
InMemoryCache
({
addTypename
:
false
,
fragmentMatcher
,
dataIdFromObject
:
object
=>
{
switch
(
object
.
__typename
)
{
case
'
Identity
'
:
return
object
.
hash
case
'
Event
'
:
return
object
.
block
.
number
case
'
EventId
'
:
return
`
${
object
.
member
.
hash
}
:
${
object
.
inOut
}
`
case
'
Forecast
'
:
return
`
${
object
.
member
.
hash
}
:
${
object
.
date
}
:
${
object
.
after
}
:
${
object
.
proba
}
`
default
:
return
defaultDataIdFromObject
(
object
);
// fall back to default handling
}
}
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
graphql/endpoint.js
→
graphql/endpoint
s
.js
+
3
−
0
View file @
c44a2f42
module
.
exports
=
{
ENDPOINT
:
'
https://wwgql.coinduf.eu
'
ENDPOINT
1
:
'
https://wwgql.coinduf.eu
'
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
graphql/index.js
+
4
−
25
View file @
c44a2f42
import
{
HttpLink
}
from
'
apollo-link-http
'
import
{
setContext
}
from
'
apollo-link-context
'
import
{
from
}
from
'
apollo-link
'
import
{
InMemoryCache
,
IntrospectionFragmentMatcher
,
defaultDataIdFromObject
}
from
'
apollo-cache-inmemory
'
import
{
ENDPOINT
}
from
'
./endpoint
'
import
introspectionQueryResultData
from
'
./fragmentTypes.json
'
;
import
{
ENDPOINT
1
}
from
'
./endpoint
s
'
import
{
cache
}
from
'
./cache
'
export
default
ctx
=>
{
const
ssrMiddleware
=
setContext
((
_
,
{
headers
})
=>
{
...
...
@@ -15,33 +14,13 @@ export default ctx => {
})
const
httpLink
=
new
HttpLink
({
uri
:
ENDPOINT
uri
:
ENDPOINT
1
})
const
link
=
from
([
ssrMiddleware
,
httpLink
])
const
fragmentMatcher
=
new
IntrospectionFragmentMatcher
({
introspectionQueryResultData
})
// Apparemment il faut utiliser la syntaxe Apollo v2
const
cache
=
new
InMemoryCache
({
addTypename
:
false
,
fragmentMatcher
,
dataIdFromObject
:
object
=>
{
switch
(
object
.
__typename
)
{
case
'
Identity
'
:
return
object
.
hash
case
'
Event
'
:
return
object
.
block
.
number
case
'
EventId
'
:
return
`
${
object
.
member
.
hash
}
:
${
object
.
inOut
}
`
case
'
Forecast
'
:
return
`
${
object
.
member
.
hash
}
:
${
object
.
date
}
:
${
object
.
after
}
:
${
object
.
proba
}
`
default
:
return
defaultDataIdFromObject
(
object
);
// fall back to default handling
}
}
})
return
{
link
,
cache
,
defaultHttpLink
:
false
cache
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
graphql/schemaQuery.js
+
2
−
2
View file @
c44a2f42
const
{
ENDPOINT
}
=
require
(
'
./endpoint
'
);
const
{
ENDPOINT
1
}
=
require
(
'
./endpoint
s
'
);
const
fetch
=
require
(
'
node-fetch
'
);
const
fs
=
require
(
'
fs
'
);
fetch
(
ENDPOINT
,
{
fetch
(
ENDPOINT
1
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
},
body
:
JSON
.
stringify
({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment