-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to make sure important errors are still surfaced
- Loading branch information
Showing
17 changed files
with
617 additions
and
6 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/internal/src/__tests__/fixtures/.redwood/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
174
packages/internal/src/__tests__/fixtures/api/types/graphql.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
|
21 changes: 21 additions & 0 deletions
21
.../internal/src/__tests__/fixtures/typeDefinitions/invalidQueryType/.redwood/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/internal/src/__tests__/fixtures/typeDefinitions/invalidQueryType/redwood.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[web] | ||
port = 8910 |
7 changes: 7 additions & 0 deletions
7
packages/internal/src/__tests__/fixtures/typeDefinitions/invalidQueryType/web/src/gql.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
` |
55 changes: 55 additions & 0 deletions
55
...s/internal/src/__tests__/fixtures/typeDefinitions/invalidQueryType/web/types/graphql.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
25 changes: 25 additions & 0 deletions
25
packages/internal/src/__tests__/fixtures/typeDefinitions/missingType/.redwood/schema.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/internal/src/__tests__/fixtures/typeDefinitions/missingType/redwood.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[web] | ||
port = 8910 |
8 changes: 8 additions & 0 deletions
8
packages/internal/src/__tests__/fixtures/typeDefinitions/missingType/web/src/gql.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
` |
55 changes: 55 additions & 0 deletions
55
packages/internal/src/__tests__/fixtures/typeDefinitions/missingType/web/types/graphql.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
Oops, something went wrong.