Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
fix(gg): dedupe nullable on optional non-array interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Jan 25, 2019
1 parent 6b66923 commit 17cdb85
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/graphqlgen/src/generators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ export const printFieldLikeType = (

if (field.type.isArray) {
rendering = array(rendering, { innerUnion: false })
}

if (!field.type.isArrayRequired) {
rendering = nullable(rendering)
if (!field.type.isArrayRequired) {
rendering = nullable(rendering)
}
}

// We do not have to handle defaults becuase graphql only
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type Query {
media(first: Int): [Media]
mediaItem(id: Int!): Media
}

interface Unused {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ export namespace QueryResolvers {
first?: number | null;
}

export interface ArgsMediaItem {
id: number;
}

export type MediaResolver = (
parent: undefined,
args: ArgsMedia,
Expand All @@ -360,6 +364,13 @@ export namespace QueryResolvers {
| null
| Promise<Array<Image | Video | null> | null>;

export type MediaItemResolver = (
parent: undefined,
args: ArgsMediaItem,
ctx: Context,
info: GraphQLResolveInfo
) => Image | Video | null | Promise<Image | Video | null>;

export interface Type {
media: (
parent: undefined,
Expand All @@ -370,6 +381,13 @@ export namespace QueryResolvers {
| Array<Image | Video | null>
| null
| Promise<Array<Image | Video | null> | null>;

mediaItem: (
parent: undefined,
args: ArgsMediaItem,
ctx: Context,
info: GraphQLResolveInfo
) => Image | Video | null | Promise<Image | Video | null>;
}
}

Expand Down Expand Up @@ -615,6 +633,9 @@ export const Query: QueryResolvers.Type = {
...QueryResolvers.defaultResolvers,
media: (parent, args, ctx) => {
throw new Error(\\"Resolver not implemented\\");
},
mediaItem: (parent, args, ctx) => {
throw new Error(\\"Resolver not implemented\\");
}
};
",
Expand Down

0 comments on commit 17cdb85

Please sign in to comment.