Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engélibert
duniter
Commits
97ea85ce
Commit
97ea85ce
authored
4 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] gva: expose function to build schema
parent
25ef748a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rust-libs/modules/gva/src/lib.rs
+26
-33
26 additions, 33 deletions
rust-libs/modules/gva/src/lib.rs
rust-libs/modules/gva/src/schema.rs
+27
-1
27 additions, 1 deletion
rust-libs/modules/gva/src/schema.rs
with
53 additions
and
34 deletions
rust-libs/modules/gva/src/lib.rs
+
26
−
33
View file @
97ea85ce
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
)]
)]
pub
use
duniter_conf
::
gva_conf
::
GvaConf
;
pub
use
duniter_conf
::
gva_conf
::
GvaConf
;
pub
use
schema
::{
build_schema
,
GraphQlSchema
};
mod
anti_spam
;
mod
anti_spam
;
mod
entities
;
mod
entities
;
...
@@ -45,7 +46,7 @@ use crate::entities::{
...
@@ -45,7 +46,7 @@ use crate::entities::{
use
crate
::
inputs
::{
TxIssuer
,
TxRecipient
,
UdsFilter
};
use
crate
::
inputs
::{
TxIssuer
,
TxRecipient
,
UdsFilter
};
use
crate
::
inputs_validators
::
TxCommentValidator
;
use
crate
::
inputs_validators
::
TxCommentValidator
;
use
crate
::
pagination
::
Pagination
;
use
crate
::
pagination
::
Pagination
;
use
crate
::
schema
::
{
GraphQlSchema
,
SchemaData
}
;
use
crate
::
schema
::
SchemaData
;
#[cfg(test)]
#[cfg(test)]
use
crate
::
tests
::
create_dbs_reader
;
use
crate
::
tests
::
create_dbs_reader
;
#[cfg(test)]
#[cfg(test)]
...
@@ -298,12 +299,8 @@ impl GvaModule {
...
@@ -298,12 +299,8 @@ impl GvaModule {
software_version
:
&
'static
str
,
software_version
:
&
'static
str
,
)
{
)
{
log
::
info!
(
"GvaServer::start: conf={:?}"
,
conf
);
log
::
info!
(
"GvaServer::start: conf={:?}"
,
conf
);
let
schema
=
async_graphql
::
Schema
::
build
(
let
schema
=
schema
::
build_schema_with_data
(
queries
::
QueryRoot
::
default
(),
schema
::
SchemaData
{
mutations
::
MutationRoot
::
default
(),
subscriptions
::
SubscriptionRoot
::
default
(),
)
.data
(
schema
::
SchemaData
{
dbs_reader
:
create_dbs_reader
(
gva_db_ro
),
dbs_reader
:
create_dbs_reader
(
gva_db_ro
),
dbs_pool
,
dbs_pool
,
server_meta_data
:
ServerMetaData
{
server_meta_data
:
ServerMetaData
{
...
@@ -312,9 +309,9 @@ impl GvaModule {
...
@@ -312,9 +309,9 @@ impl GvaModule {
software_version
,
software_version
,
},
},
txs_mempool
:
mempools
.txs
,
txs_mempool
:
mempools
.txs
,
})
},
.extension
(
async_graphql
::
extensions
::
Logger
)
true
,
.finish
(
);
);
let
graphql_post
=
warp_
::
graphql
(
let
graphql_post
=
warp_
::
graphql
(
&
conf
,
&
conf
,
...
@@ -477,12 +474,8 @@ mod tests {
...
@@ -477,12 +474,8 @@ mod tests {
pub
(
crate
)
fn
create_schema
(
dbs_ops
:
MockDbsReader
)
->
KvResult
<
GraphQlSchema
>
{
pub
(
crate
)
fn
create_schema
(
dbs_ops
:
MockDbsReader
)
->
KvResult
<
GraphQlSchema
>
{
let
dbs
=
SharedDbs
::
mem
()
?
;
let
dbs
=
SharedDbs
::
mem
()
?
;
let
threadpool
=
fast_threadpool
::
ThreadPool
::
start
(
ThreadPoolConfig
::
default
(),
dbs
);
let
threadpool
=
fast_threadpool
::
ThreadPool
::
start
(
ThreadPoolConfig
::
default
(),
dbs
);
Ok
(
async_graphql
::
Schema
::
build
(
Ok
(
schema
::
build_schema_with_data
(
queries
::
QueryRoot
::
default
(),
schema
::
SchemaData
{
mutations
::
MutationRoot
::
default
(),
subscriptions
::
SubscriptionRoot
::
default
(),
)
.data
(
schema
::
SchemaData
{
dbs_pool
:
threadpool
.into_async_handler
(),
dbs_pool
:
threadpool
.into_async_handler
(),
dbs_reader
:
Arc
::
new
(
dbs_ops
),
dbs_reader
:
Arc
::
new
(
dbs_ops
),
server_meta_data
:
ServerMetaData
{
server_meta_data
:
ServerMetaData
{
...
@@ -491,9 +484,9 @@ mod tests {
...
@@ -491,9 +484,9 @@ mod tests {
software_version
:
"test"
,
software_version
:
"test"
,
},
},
txs_mempool
:
TxsMempool
::
new
(
10
),
txs_mempool
:
TxsMempool
::
new
(
10
),
})
},
.extension
(
async_graphql
::
extensions
::
Logger
)
true
,
.finish
(
))
))
}
}
pub
(
crate
)
async
fn
exec_graphql_request
(
pub
(
crate
)
async
fn
exec_graphql_request
(
...
...
This diff is collapsed.
Click to expand it.
rust-libs/modules/gva/src/schema.rs
+
27
−
1
View file @
97ea85ce
...
@@ -15,11 +15,37 @@
...
@@ -15,11 +15,37 @@
use
crate
::
*
;
use
crate
::
*
;
pub
(
crate
)
type
GraphQlSchema
=
async_graphql
::
Schema
<
pub
type
GraphQlSchema
=
async_graphql
::
Schema
<
crate
::
queries
::
QueryRoot
,
crate
::
queries
::
QueryRoot
,
crate
::
mutations
::
MutationRoot
,
crate
::
mutations
::
MutationRoot
,
crate
::
subscriptions
::
SubscriptionRoot
,
crate
::
subscriptions
::
SubscriptionRoot
,
>
;
>
;
pub
fn
build_schema
(
logger
:
bool
)
->
GraphQlSchema
{
let
mut
builder
=
async_graphql
::
Schema
::
build
(
queries
::
QueryRoot
::
default
(),
mutations
::
MutationRoot
::
default
(),
subscriptions
::
SubscriptionRoot
::
default
(),
);
if
logger
{
builder
=
builder
.extension
(
async_graphql
::
extensions
::
Logger
);
}
builder
.finish
()
}
pub
(
crate
)
fn
build_schema_with_data
(
data
:
SchemaData
,
logger
:
bool
)
->
GraphQlSchema
{
let
mut
builder
=
async_graphql
::
Schema
::
build
(
queries
::
QueryRoot
::
default
(),
mutations
::
MutationRoot
::
default
(),
subscriptions
::
SubscriptionRoot
::
default
(),
)
.data
(
data
);
if
logger
{
builder
=
builder
.extension
(
async_graphql
::
extensions
::
Logger
);
}
builder
.finish
()
}
pub
(
crate
)
struct
SchemaData
{
pub
(
crate
)
struct
SchemaData
{
pub
(
crate
)
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
pub
(
crate
)
dbs_pool
:
fast_threadpool
::
ThreadPoolAsyncHandler
<
SharedDbs
<
FileBackend
>>
,
pub
(
crate
)
dbs_reader
:
DbsReader
,
pub
(
crate
)
dbs_reader
:
DbsReader
,
...
...
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