Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gdd-sigma-poc
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Guillaume WANG
gdd-sigma-poc
Commits
4a9d4856
Commit
4a9d4856
authored
7 years ago
by
Wilson JALLET
Browse files
Options
Downloads
Patches
Plain Diff
Un-breaking stuff
parent
6beabd02
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/graphql/schema.js
+8
-6
8 additions, 6 deletions
src/graphql/schema.js
src/ldap/ldap_data.js
+0
-1
0 additions, 1 deletion
src/ldap/ldap_data.js
src/server.js
+10
-2
10 additions, 2 deletions
src/server.js
with
18 additions
and
9 deletions
src/graphql/schema.js
+
8
−
6
View file @
4a9d4856
...
...
@@ -4,14 +4,14 @@
*/
import
knex
from
'
../../db/knex_router
'
;
import
{
listGroups
,
listMembers
}
from
'
../ldap/ldap_data
'
;
//
import { listGroups, listMembers
} from '../ldap/ldap_data';
import
{
makeExecutableSchema
}
from
'
graphql-tools
'
;
import
{
request
}
from
'
https
'
;
const
typeDefs
=
`
type Query {
allGroups: [Group]
!
group(id
: ID) : Group
!
allGroups: [Group]
group(id: ID) :
[
Group
]
}
type Group {
...
...
@@ -25,12 +25,13 @@ const typeDefs = `
`
;
const
getAllVisibleGroups
=
(
user
)
=>
{
let
group_ids
=
listGroups
(
user
.
id
);
return
knex
.
select
().
from
(
'
groups
'
).
whereIn
(
'
id
'
,
group_ids
);
//
let group_ids = listGroups(user.id);
return
knex
.
select
().
from
(
'
groups
'
)
/*
.whereIn('id', group_ids)
*/
;
};
const
getGroupIfVisible
=
(
user
,
id
)
=>
{
return
this
.
getAllVisibleGroups
(
user
).
where
(
'
id
'
,
id
);
return
getAllVisibleGroups
(
user
)
/*.where('id', id).then(function(table) {
console.log(JSON.stringify(table,null,2))*/
;
};
const
resolvers
=
{
...
...
@@ -39,6 +40,7 @@ const resolvers = {
return
getAllVisibleGroups
(
context
.
user
);
},
group
:
(
obj
,
args
,
context
)
=>
{
console
.
log
(
args
.
id
);
return
getGroupIfVisible
(
context
.
user
,
args
.
id
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/ldap/ldap_data.js
+
0
−
1
View file @
4a9d4856
...
...
@@ -116,7 +116,6 @@ function TOL(c0="", c1="", c2="", c3="", c4="", c5="", c6="", c7="", c8="", c9="
// Synthaxe d'utilisation
//listGroups("quentin.louis").then((meList) => { console.log(meList); });
TOL
(
""
,
""
,
""
,
""
,
""
,
""
,
"
faerix
"
,
""
,
""
,
""
,
""
,
""
,
""
).
then
((
meList
)
=>
{
console
.
log
(
meList
);
});
/* Partage pour le reste du monde ; même remarque synthaxe
export { listGroups, listMembers, TOL }; */
...
...
This diff is collapsed.
Click to expand it.
src/server.js
+
10
−
2
View file @
4a9d4856
...
...
@@ -32,11 +32,19 @@ server.use(favicon(path.resolve('./','assets','favicon.ico')));
server
.
use
(
morgan
(
'
dev
'
));
// Charge le middleware express pour GraphQL
server
.
use
(
'
/graphql
'
,
bodyParser
.
json
(),
server
.
use
(
'
/graphql
'
,
bodyParser
.
json
(),
cors
(),
graphqlExpress
(
req
=>
{
let
uid
;
try
{
uid
=
req
.
session
.
id
;
}
catch
(
err
)
{
uid
=
"
1
"
;
}
return
{
schema
:
schema
,
context
:
{
user
:
{
id
:
req
.
session
.
id
}}
context
:
{
user
:
{
id
:
u
id
}}
};
}));
...
...
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