Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodlenet
nodejs-services
Commits
600faa2c
Commit
600faa2c
authored
Oct 06, 2020
by
aleclofabbro
Browse files
refactror names
parent
3c193de9
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/gql-
c
ra
wl
/defaultGraphFieldResolver.ts
→
src/gql-
g
ra
ph
/defaultGraphFieldResolver.ts
View file @
600faa2c
import
{
Context
}
from
'
../gql
'
import
{
ResolverFn
}
from
'
../gql/types
'
import
{
ShallowTypes
}
from
'
../gql/shallowTypes
'
import
{
ShallowType
Mock
s
}
from
'
../gql/shallowTypes
'
import
{
typeInfo
,
getParent
}
from
'
./graphQuery
'
import
{
GraphQueryObj
}
from
'
./types
'
...
...
@@ -9,7 +9,7 @@ export function defaultGraphFieldResolver(): ResolverFn<any, any, Context, any>
if
(
!
context
.
$graph
)
{
context
.
$graph
=
{
qObj
:
{
type
name
:
'
Query
'
,
type
:
'
Query
'
,
query
:
undefined
,
traverse
:
[],
alias
:
'
Query
'
,
...
...
@@ -40,14 +40,14 @@ export function defaultGraphFieldResolver(): ResolverFn<any, any, Context, any>
traverse
:
[],
select
:
[],
query
:
args
?.
query
[
typename
],
typename
,
type
:
typename
,
alias
:
`
${
info
.
path
.
key
}
`
,
}))
)
const
fieldReturn
=
__typenames
.
map
((
__typename
)
=>
{
const
type
=
(
__typename
as
any
)
as
keyof
ShallowTypes
const
obj
=
ShallowTypes
[
type
](
`
${
info
.
path
.
key
}
:
${
fieldName
}
:
${
type
}
`
)
const
type
=
(
__typename
as
any
)
as
keyof
ShallowType
Mock
s
const
obj
=
ShallowType
Mock
s
[
type
](
`
${
info
.
path
.
key
}
:
${
fieldName
}
:
${
type
}
`
)
console
.
log
(
'
*
'
,
type
,
obj
)
return
obj
})
...
...
src/gql-
c
ra
wl
/graphQuery.ts
→
src/gql-
g
ra
ph
/graphQuery.ts
View file @
600faa2c
File moved
src/gql-
c
ra
wl
/mongo/mappers.ts
→
src/gql-
g
ra
ph
/mongo/mappers.ts
View file @
600faa2c
File moved
src/gql-
c
ra
wl
/types.d.ts
→
src/gql-
g
ra
ph
/types.d.ts
View file @
600faa2c
...
...
@@ -14,7 +14,7 @@ export type GraphQuery = {
}
export
type
GraphQueryObj
=
{
type
name
:
string
type
:
string
query
:
any
select
:
Selection
[]
traverse
:
GraphQueryObj
[]
...
...
src/gql/index.ts
View file @
600faa2c
...
...
@@ -4,7 +4,7 @@ import { applyMiddleware } from 'graphql-middleware'
import
{
resolvers
}
from
'
./resolvers
'
import
{
directiveResolvers
}
from
'
./directives
'
import
{
middlewares
}
from
'
./middlewares
'
import
{
GraphQuery
}
from
'
../gql-
c
ra
wl
/types
'
import
{
GraphQuery
}
from
'
../gql-
g
ra
ph
/types
'
export
type
Context
=
{
$graph
?:
GraphQuery
...
...
src/gql/resolvers/mutation/createUser.ts
View file @
600faa2c
import
{
collection
}
from
'
../../../mongo/collection
'
import
{
toMongoNode
}
from
'
../../../gql-
c
ra
wl
/mongo/mappers
'
import
{
toMongoNode
}
from
'
../../../gql-
g
ra
ph
/mongo/mappers
'
import
{
MutationResolvers
,
User
}
from
'
../../types
'
export
const
createUser
:
MutationResolvers
[
'
createUser
'
]
=
async
(
...
...
src/gql/resolvers/query/index.ts
View file @
600faa2c
import
{
defaultGraphFieldResolver
}
from
'
../../../gql-
c
ra
wl
/defaultGraphFieldResolver
'
import
{
defaultGraphFieldResolver
}
from
'
../../../gql-
g
ra
ph
/defaultGraphFieldResolver
'
import
{
QueryResolvers
}
from
'
../../types
'
export
const
Query
:
QueryResolvers
=
{
...
...
src/gql/resolvers/types/index.ts
View file @
600faa2c
import
{
defaultGraphFieldResolver
}
from
'
../../../gql-
c
ra
wl
/defaultGraphFieldResolver
'
import
{
defaultGraphFieldResolver
}
from
'
../../../gql-
g
ra
ph
/defaultGraphFieldResolver
'
export
const
Types
=
{
User
:
{
_id
:
defaultGraphFieldResolver
(),
...
...
src/gql/shallowTypes/Follows.ts
View file @
600faa2c
import
{
ShallowRelation
}
from
'
../../gql-
c
ra
wl
/types
'
import
{
ShallowRelation
}
from
'
../../gql-
g
ra
ph
/types
'
import
*
as
Types
from
'
../types
'
export
const
Follows
=
(
tag
:
string
):
ShallowRelation
<
Types
.
Follows
>
=>
({
...
...
src/gql/shallowTypes/Knows.ts
View file @
600faa2c
import
{
ShallowRelation
}
from
'
../../gql-
c
ra
wl
/types
'
import
{
ShallowRelation
}
from
'
../../gql-
g
ra
ph
/types
'
import
*
as
Types
from
'
../types
'
export
const
Knows
=
(
tag
:
string
):
ShallowRelation
<
Types
.
Knows
>
=>
({
...
...
src/gql/shallowTypes/User.ts
View file @
600faa2c
import
{
ShallowEntity
}
from
'
../../gql-
c
ra
wl
/types
'
import
{
ShallowEntity
}
from
'
../../gql-
g
ra
ph
/types
'
import
*
as
Types
from
'
../types
'
export
const
User
=
(
tag
:
string
):
ShallowEntity
<
Types
.
User
>
=>
({
__typename
:
'
User
'
,
...
...
src/gql/shallowTypes/index.ts
View file @
600faa2c
...
...
@@ -2,8 +2,8 @@ import { Follows } from './Follows'
import
{
Knows
}
from
'
./Knows
'
import
{
User
}
from
'
./User
'
export
type
ShallowTypes
=
typeof
ShallowTypes
export
const
ShallowTypes
=
{
export
type
ShallowType
Mock
s
=
typeof
ShallowType
Mock
s
export
const
ShallowType
Mock
s
=
{
User
,
Knows
,
Follows
,
...
...
src/mongo/collection.ts
View file @
600faa2c
import
{
MongoNode
,
MongoRelation
}
from
'
../gql-
c
ra
wl
/mongo/mappers
'
import
{
GqlType
,
GqlNode
,
GqlRelation
}
from
'
../gql-
c
ra
wl
/types
'
import
{
MongoNode
,
MongoRelation
}
from
'
../gql-
g
ra
ph
/mongo/mappers
'
import
{
GqlType
,
GqlNode
,
GqlRelation
}
from
'
../gql-
g
ra
ph
/types
'
import
{
DB
}
from
'
./
'
export
const
collection
=
async
<
E
extends
GqlType
>
(
name
:
E
[
'
__typename
'
])
=>
...
...
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