prisma-labs/graphqlgen

GraphQL defaults should strip null

jasonkuhrt opened this issue · 0 comments

Description

Given this schema:

type Query {
  pants(size: Int = 10): Int
}

the types generated are:

export namespace QueryResolvers {
  export const defaultResolvers = {};

  export interface ArgsPants {
    size: number | null;
  }

  export type PantsResolver = (
    parent: undefined,
    args: ArgsPants,
    ctx: Context,
    info: GraphQLResolveInfo
  ) => number | null | Promise<number | null>;

  export interface Type {
    pants: (
      parent: undefined,
      args: ArgsPants,
      ctx: Context,
      info: GraphQLResolveInfo
    ) => number | null | Promise<number | null>;
  }
}

Note the | null here:

  export interface ArgsPants {
    size: number | null;
  }

But, we have setup a default in our graphql schema:

size: Int = 10

So, the type that should be generated is:

  export interface ArgsPants {
    size: number;
  }