Commit 600faa2c authored by aleclofabbro's avatar aleclofabbro
Browse files

refactror names

parent 3c193de9
import { Context } from '../gql'
import { ResolverFn } from '../gql/types'
import { ShallowTypes } from '../gql/shallowTypes'
import { ShallowTypeMocks } 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: {
typename: '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 ShallowTypeMocks
const obj = ShallowTypeMocks[type](`${info.path.key}:${fieldName} : ${type}`)
console.log('*', type, obj)
return obj
})
......
......@@ -14,7 +14,7 @@ export type GraphQuery = {
}
export type GraphQueryObj = {
typename: string
type: string
query: any
select: Selection[]
traverse: GraphQueryObj[]
......
......@@ -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-crawl/types'
import { GraphQuery } from '../gql-graph/types'
export type Context = {
$graph?: GraphQuery
......
import { collection } from '../../../mongo/collection'
import { toMongoNode } from '../../../gql-crawl/mongo/mappers'
import { toMongoNode } from '../../../gql-graph/mongo/mappers'
import { MutationResolvers, User } from '../../types'
export const createUser: MutationResolvers['createUser'] = async (
......
import { defaultGraphFieldResolver } from '../../../gql-crawl/defaultGraphFieldResolver'
import { defaultGraphFieldResolver } from '../../../gql-graph/defaultGraphFieldResolver'
import { QueryResolvers } from '../../types'
export const Query: QueryResolvers = {
......
import { defaultGraphFieldResolver } from '../../../gql-crawl/defaultGraphFieldResolver'
import { defaultGraphFieldResolver } from '../../../gql-graph/defaultGraphFieldResolver'
export const Types = {
User: {
_id: defaultGraphFieldResolver(),
......
import { ShallowRelation } from '../../gql-crawl/types'
import { ShallowRelation } from '../../gql-graph/types'
import * as Types from '../types'
export const Follows = (tag: string): ShallowRelation<Types.Follows> => ({
......
import { ShallowRelation } from '../../gql-crawl/types'
import { ShallowRelation } from '../../gql-graph/types'
import * as Types from '../types'
export const Knows = (tag: string): ShallowRelation<Types.Knows> => ({
......
import { ShallowEntity } from '../../gql-crawl/types'
import { ShallowEntity } from '../../gql-graph/types'
import * as Types from '../types'
export const User = (tag: string): ShallowEntity<Types.User> => ({
__typename: 'User',
......
......@@ -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 ShallowTypeMocks = typeof ShallowTypeMocks
export const ShallowTypeMocks = {
User,
Knows,
Follows,
......
import { MongoNode, MongoRelation } from '../gql-crawl/mongo/mappers'
import { GqlType, GqlNode, GqlRelation } from '../gql-crawl/types'
import { MongoNode, MongoRelation } from '../gql-graph/mongo/mappers'
import { GqlType, GqlNode, GqlRelation } from '../gql-graph/types'
import { DB } from './'
export const collection = async <E extends GqlType>(name: E['__typename']) =>
......
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