Skip to content

Commit

Permalink
Add tests to make sure important errors are still surfaced
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Mar 15, 2022
1 parent f7a488d commit 1586f6b
Show file tree
Hide file tree
Showing 17 changed files with 617 additions and 6 deletions.
31 changes: 31 additions & 0 deletions packages/internal/src/__tests__/fixtures/.redwood/schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
scalar BigInt

scalar Date

scalar DateTime

scalar JSON

scalar JSONObject

type Mutation {
createTodo(body: String!): Todo
}

type Query {
redwood: Redwood
}

type Redwood {
currentUser: JSON
prismaVersion: String
version: String
}

scalar Time

type Todo {
body: String!
id: Int!
status: String!
}
174 changes: 174 additions & 0 deletions packages/internal/src/__tests__/fixtures/api/types/graphql.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
BigInt: number;
Date: string;
DateTime: string;
JSON: Record<string, unknown>;
JSONObject: Record<string, unknown>;
Time: string;
};

export type Query = {
__typename?: 'Query';
redwood?: Maybe<Redwood>;
};

export type Redwood = {
__typename?: 'Redwood';
currentUser?: Maybe<Scalars['JSON']>;
prismaVersion?: Maybe<Scalars['String']>;
version?: Maybe<Scalars['String']>;
};



export type ResolverTypeWrapper<T> = Promise<T> | T;


export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
};
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> = ResolverFn<TResult, TParent, TContext, TArgs> | ResolverWithResolve<TResult, TParent, TContext, TArgs>;

export type ResolverFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => Promise<TResult> | TResult;

export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterable<TResult> | Promise<AsyncIterable<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;

export interface SubscriptionSubscriberObject<TResult, TKey extends string, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>;
resolve?: SubscriptionResolveFn<TResult, { [key in TKey]: TResult }, TContext, TArgs>;
}

export interface SubscriptionResolverObject<TResult, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<any, TParent, TContext, TArgs>;
resolve: SubscriptionResolveFn<TResult, any, TContext, TArgs>;
}

export type SubscriptionObject<TResult, TKey extends string, TParent, TContext, TArgs> =
| SubscriptionSubscriberObject<TResult, TKey, TParent, TContext, TArgs>
| SubscriptionResolverObject<TResult, TParent, TContext, TArgs>;

export type SubscriptionResolver<TResult, TKey extends string, TParent = {}, TContext = {}, TArgs = {}> =
| ((...args: any[]) => SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>)
| SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>;

export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
parent: TParent,
context: TContext,
info: GraphQLResolveInfo
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;

export type IsTypeOfResolverFn<T = {}, TContext = {}> = (obj: T, context: TContext, info: GraphQLResolveInfo) => boolean | Promise<boolean>;

export type NextResolverFn<T> = () => Promise<T>;

export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs = {}> = (
next: NextResolverFn<TResult>,
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;

/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
BigInt: ResolverTypeWrapper<Scalars['BigInt']>;
Boolean: ResolverTypeWrapper<Scalars['Boolean']>;
Date: ResolverTypeWrapper<Scalars['Date']>;
DateTime: ResolverTypeWrapper<Scalars['DateTime']>;
JSON: ResolverTypeWrapper<Scalars['JSON']>;
JSONObject: ResolverTypeWrapper<Scalars['JSONObject']>;
Query: ResolverTypeWrapper<{}>;
Redwood: ResolverTypeWrapper<Redwood>;
String: ResolverTypeWrapper<Scalars['String']>;
Time: ResolverTypeWrapper<Scalars['Time']>;
};

/** Mapping between all available schema types and the resolvers parents */
export type ResolversParentTypes = {
BigInt: Scalars['BigInt'];
Boolean: Scalars['Boolean'];
Date: Scalars['Date'];
DateTime: Scalars['DateTime'];
JSON: Scalars['JSON'];
JSONObject: Scalars['JSONObject'];
Query: {};
Redwood: Redwood;
String: Scalars['String'];
Time: Scalars['Time'];
};

export interface BigIntScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['BigInt'], any> {
name: 'BigInt';
}

export interface DateScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Date'], any> {
name: 'Date';
}

export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['DateTime'], any> {
name: 'DateTime';
}

export interface JSONScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['JSON'], any> {
name: 'JSON';
}

export interface JSONObjectScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['JSONObject'], any> {
name: 'JSONObject';
}

export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
redwood?: Resolver<Maybe<ResolversTypes['Redwood']>, ParentType, ContextType>;
};

export type RedwoodResolvers<ContextType = any, ParentType extends ResolversParentTypes['Redwood'] = ResolversParentTypes['Redwood']> = {
currentUser?: Resolver<Maybe<ResolversTypes['JSON']>, ParentType, ContextType>;
prismaVersion?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
version?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

export interface TimeScalarConfig extends GraphQLScalarTypeConfig<ResolversTypes['Time'], any> {
name: 'Time';
}

export type Resolvers<ContextType = any> = {
BigInt?: GraphQLScalarType;
Date?: GraphQLScalarType;
DateTime?: GraphQLScalarType;
JSON?: GraphQLScalarType;
JSONObject?: GraphQLScalarType;
Query?: QueryResolvers<ContextType>;
Redwood?: RedwoodResolvers<ContextType>;
Time?: GraphQLScalarType;
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
scalar BigInt

scalar Date

scalar DateTime

scalar JSON

scalar JSONObject

scalar Time

type Query {
redwood: Redwood
}

type Redwood {
currentUser: JSON
prismaVersion: String
version: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[web]
port = 8910
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const someOtherQuery = gql`
query FindSoftKitten($id: String!) {
softKitten: softKitten(id: $id) {
id
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
BigInt: number;
Date: string;
DateTime: string;
JSON: Record<string, unknown>;
JSONObject: Record<string, unknown>;
Time: string;
};

export type Mutation = {
__typename?: 'Mutation';
createTodo?: Maybe<Todo>;
};


export type MutationcreateTodoArgs = {
body: Scalars['String'];
};

export type Query = {
__typename?: 'Query';
redwood?: Maybe<Redwood>;
};

export type Redwood = {
__typename?: 'Redwood';
currentUser?: Maybe<Scalars['JSON']>;
prismaVersion?: Maybe<Scalars['String']>;
version?: Maybe<Scalars['String']>;
};

export type Todo = {
__typename?: 'Todo';
body: Scalars['String'];
id: Scalars['Int'];
status: Scalars['String'];
};

export type AddTodo_CreateTodo_CellVariables = Exact<{
body: Scalars['String'];
}>;


export type AddTodo_CreateTodo_Cell = { __typename?: 'Mutation', createTodo?: { __typename?: 'Todo', id: number, body: string } | null };
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
scalar BigInt

scalar Date

scalar DateTime

scalar JSON

scalar JSONObject

scalar Time

type Mutation {
createTodo(body: String!): Todo
}

type Query {
redwood: Redwood
}

type Redwood {
currentUser: JSON
prismaVersion: String
version: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[web]
port = 8910
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const CREATE_TODO_CELL = gql`
mutation AddTodo_CreateTodo_Cell($body: String!) {
createTodo(body: $body) {
id
task
}
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
BigInt: number;
Date: string;
DateTime: string;
JSON: Record<string, unknown>;
JSONObject: Record<string, unknown>;
Time: string;
};

export type Mutation = {
__typename?: 'Mutation';
createTodo?: Maybe<Todo>;
};


export type MutationcreateTodoArgs = {
body: Scalars['String'];
};

export type Query = {
__typename?: 'Query';
redwood?: Maybe<Redwood>;
};

export type Redwood = {
__typename?: 'Redwood';
currentUser?: Maybe<Scalars['JSON']>;
prismaVersion?: Maybe<Scalars['String']>;
version?: Maybe<Scalars['String']>;
};

export type Todo = {
__typename?: 'Todo';
body: Scalars['String'];
id: Scalars['Int'];
status: Scalars['String'];
};

export type AddTodo_CreateTodo_CellVariables = Exact<{
body: Scalars['String'];
}>;


export type AddTodo_CreateTodo_Cell = { __typename?: 'Mutation', createTodo?: { __typename?: 'Todo', id: number, body: string } | null };
Loading

0 comments on commit 1586f6b

Please sign in to comment.