Commit feb5f1ea authored by aleclofabbro's avatar aleclofabbro
Browse files

fake return entities, no hack in graphql pkg

parent 6181a1b3
import * as Types from '../types'
export type Fakes = typeof Fakes
export const Fakes = {
User: (tag: string): Omit<Types.User, '_rel'> => ({
__typename: 'User',
_id: `_id[${tag}]`,
username: `username[${tag}]`,
}),
Knows: (tag: string): Omit<Types.Knows, '_obj' | '_subj'> => ({
__typename: 'Knows',
_id: `_id[${tag}]`,
}),
Follows: (tag: string): Omit<Types.Follows, '_obj' | '_subj'> => ({
__typename: 'Follows',
_id: `_id[${tag}]`,
}),
}
......@@ -11,6 +11,7 @@ import {
import { Context } from '../..'
import { getParent } from '../../../mongo/helpers/graphQuery'
import { GraphQueryObj } from '../../../mongo/types'
import { Fakes } from '../../fakes'
import { typeInfo } from '../../helpers/info'
import { ResolverFn, Resolvers, TypeResolveFn } from '../../types'
export const Types = {
......@@ -72,15 +73,21 @@ export function defaultGraphFieldResolver(): ResolverFn<any, any, Context, any>
}))
)
const fieldReturn = __typenames.map((__typename) => ({ __typename }))
console.log('fieldReturn', fieldReturn)
const fieldReturn = __typenames.map((__typename) => {
const type = (__typename as any) as keyof Fakes
const obj = Fakes[type](`${info.path.key}:${fieldName} : ${type}`)
console.log('*', type, obj)
return obj
})
console.log(`fieldReturn ${fieldName}`, fieldReturn)
return fieldReturn
} else {
if ('string' == typeof info.path.key) {
parentQ.select.push({ field: fieldName, alias: info.path.key })
}
return null
return parent[fieldName]
}
}
}
......@@ -1057,11 +1057,6 @@
dependencies:
"@types/node" "*"
"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
"@types/connect@*":
version "3.4.33"
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.33.tgz#31610c901eca573b8713c3330abc6e6b9f588546"
......@@ -1387,11 +1382,10 @@ ansi-styles@^3.2.1:
color-convert "^1.9.0"
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
dependencies:
"@types/color-name" "^1.1.1"
color-convert "^2.0.1"
any-observable@^0.3.0:
......@@ -4967,9 +4961,9 @@ uuid@^3.1.0, uuid@^3.3.2:
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
uuid@^8.0.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.0.tgz#ab738085ca22dc9a8c92725e459b1d507df5d6ea"
integrity sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==
version "8.3.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.1.tgz#2ba2e6ca000da60fce5a196954ab241131e05a31"
integrity sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==
valid-url@1.0.9, valid-url@^1.0.9:
version "1.0.9"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment