Commit 710a0d90 authored by aleclofabbro's avatar aleclofabbro
Browse files

fixed misalignment in @graphql-codegen plugins, and removed unused...

fixed misalignment in @graphql-codegen plugins, and removed unused "skipNonNullChecks" ctx flag, cleanup
parent feb5f1ea
......@@ -5,9 +5,9 @@ generates:
src/gql/types.ts:
plugins:
- "typescript"
# - "typescript-document-nodes"
- "typescript-resolvers"
# - "typescript-mongodb"
- "typescript-document-nodes"
config:
contextType: ./#Context
rootValueType: ./#RootValue
......
# directive @auth(for: Role) on FIELD_DEFINITION | OBJECT
directive @graphEntry on FIELD_DEFINITION
interface Glyph {
_id: ID!
}
......@@ -80,7 +77,7 @@ type User implements Glyph {
# Main
type Query {
user(query: UserQuery): [User!]! @graphEntry
user(query: UserQuery): [User!]!
da: Query!
}
......
import { inspect } from 'util'
import { typeInfo } from '../helpers/info'
import { DirectiveResolvers } from '../types'
export const graphEntry: DirectiveResolvers['graphEntry'] = async (
next,
parent,
args,
context,
info
) => {
// const { returnType } = info
context.skipNonNullValueChecks = true
// context.currStages = [{ match: { __typename: 'User' } }]
// context.stages = context.currStages
const result = await next()
log('graphEntry Result', result)
return result
}
const log = (..._: any[]) => console.log(inspect(_, false, 6, true))
import { DirectiveResolvers } from '../types'
import { graphEntry } from './graphEntry'
export const directiveResolvers: DirectiveResolvers = {
graphEntry,
}
// import { DirectiveResolvers } from '../types'
// export const directiveResolvers: DirectiveResolvers = {}
export const directiveResolvers = {}
......@@ -1348,18 +1348,7 @@
{
"name": "inputFields",
"description": null,
"args": [
{
"name": "includeDeprecated",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": "false"
}
],
"args": [],
"type": {
"kind": "LIST",
"name": null,
......@@ -1489,18 +1478,7 @@
{
"name": "args",
"description": null,
"args": [
{
"name": "includeDeprecated",
"description": null,
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"defaultValue": "false"
}
],
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
......@@ -1631,34 +1609,6 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "isDeprecated",
"description": null,
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "deprecationReason",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
......@@ -1964,17 +1914,8 @@
],
"directives": [
{
"name": "graphEntry",
"description": null,
"isRepeatable": false,
"locations": [
"FIELD_DEFINITION"
],
"args": []
},
{
"name": "include",
"description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
"name": "skip",
"description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
"isRepeatable": false,
"locations": [
"FIELD",
......@@ -1984,7 +1925,7 @@
"args": [
{
"name": "if",
"description": "Included when true.",
"description": "Skipped when true.",
"type": {
"kind": "NON_NULL",
"name": null,
......@@ -1999,8 +1940,8 @@
]
},
{
"name": "skip",
"description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
"name": "include",
"description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
"isRepeatable": false,
"locations": [
"FIELD",
......@@ -2010,7 +1951,7 @@
"args": [
{
"name": "if",
"description": "Skipped when true.",
"description": "Included when true.",
"type": {
"kind": "NON_NULL",
"name": null,
......@@ -2030,8 +1971,6 @@
"isRepeatable": false,
"locations": [
"FIELD_DEFINITION",
"ARGUMENT_DEFINITION",
"INPUT_FIELD_DEFINITION",
"ENUM_VALUE"
],
"args": [
......
import { DIRECTIVES } from '@graphql-codegen/typescript-mongodb'
import { makeExecutableSchema } from 'apollo-server-express'
import { typeDefs } from '../env'
import { applyMiddleware } from 'graphql-middleware'
......@@ -8,13 +7,12 @@ import { middlewares } from './middlewares'
import { GraphQuery } from '../mongo/types'
export type Context = {
skipNonNullValueChecks?: boolean
$graph?: GraphQuery
}
export type RootValue = {}
const _schema = makeExecutableSchema<Context>({
typeDefs: [DIRECTIVES, typeDefs],
typeDefs: [typeDefs],
resolvers: resolvers as any,
directiveResolvers,
})
......
import { GraphQLResolveInfo } from 'graphql';
import { Context, RootValue } from './';
import gql from 'graphql-tag';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
......@@ -14,7 +13,6 @@ export type Scalars = {
Float: number;
};
export type Glyph = {
_id: Scalars['ID'];
};
......@@ -230,7 +228,7 @@ export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
info: GraphQLResolveInfo
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;
export type IsTypeOfResolverFn<T = {}> = (obj: T, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
export type IsTypeOfResolverFn<T = {}, TContext = {}> = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise<boolean>;
export type NextResolverFn<T> = () => Promise<T>;
......@@ -305,10 +303,6 @@ export type ResolversParentTypes = {
Boolean: Scalars['Boolean'];
};
export type GraphEntryDirectiveArgs = { };
export type GraphEntryDirectiveResolver<Result, Parent, ContextType = Context, Args = GraphEntryDirectiveArgs> = DirectiveResolverFn<Result, Parent, ContextType, Args>;
export type GlyphResolvers<ContextType = Context, ParentType extends ResolversParentTypes['Glyph'] = ResolversParentTypes['Glyph']> = {
__resolveType: TypeResolveFn<'Knows' | 'Follows' | 'User', ParentType, ContextType>;
_id: Resolver<ResolversTypes['ID'], ParentType, ContextType>;
......@@ -392,13 +386,3 @@ export type Resolvers<ContextType = Context> = {
* Use "Resolvers" root object instead. If you wish to get "IResolvers", add "typesPrefix: I" to your config.
*/
export type IResolvers<ContextType = Context> = Resolvers<ContextType>;
export type DirectiveResolvers<ContextType = Context> = {
graphEntry: GraphEntryDirectiveResolver<any, any, ContextType>;
};
/**
* @deprecated
* Use "DirectiveResolvers" root object instead. If you wish to get "IDirectiveResolvers", add "typesPrefix: I" to your config.
*/
export type IDirectiveResolvers<ContextType = Context> = DirectiveResolvers<ContextType>;
\ No newline at end of file
This diff is collapsed.
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