-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
include GraphQL types as we need them inside the Github actions. Othe…
…rwise running yarn tsc fails
- Loading branch information
1 parent
1e83bc1
commit 47084bb
Showing
4 changed files
with
358 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ node_modules | |
/build | ||
/public/build | ||
# .env | ||
/app/@types | ||
|
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,66 @@ | ||
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'; | ||
import { FragmentDefinitionNode } from 'graphql'; | ||
import { Incremental } from './graphql'; | ||
|
||
|
||
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration< | ||
infer TType, | ||
any | ||
> | ||
? [TType] extends [{ ' $fragmentName'?: infer TKey }] | ||
? TKey extends string | ||
? { ' $fragmentRefs'?: { [key in TKey]: TType } } | ||
: never | ||
: never | ||
: never; | ||
|
||
// return non-nullable if `fragmentType` is non-nullable | ||
export function useFragment<TType>( | ||
_documentNode: DocumentTypeDecoration<TType, any>, | ||
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ||
): TType; | ||
// return nullable if `fragmentType` is nullable | ||
export function useFragment<TType>( | ||
_documentNode: DocumentTypeDecoration<TType, any>, | ||
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined | ||
): TType | null | undefined; | ||
// return array of non-nullable if `fragmentType` is array of non-nullable | ||
export function useFragment<TType>( | ||
_documentNode: DocumentTypeDecoration<TType, any>, | ||
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | ||
): ReadonlyArray<TType>; | ||
// return array of nullable if `fragmentType` is array of nullable | ||
export function useFragment<TType>( | ||
_documentNode: DocumentTypeDecoration<TType, any>, | ||
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined | ||
): ReadonlyArray<TType> | null | undefined; | ||
export function useFragment<TType>( | ||
_documentNode: DocumentTypeDecoration<TType, any>, | ||
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined | ||
): TType | ReadonlyArray<TType> | null | undefined { | ||
return fragmentType as any; | ||
} | ||
|
||
|
||
export function makeFragmentData< | ||
F extends DocumentTypeDecoration<any, any>, | ||
FT extends ResultOf<F> | ||
>(data: FT, _fragment: F): FragmentType<F> { | ||
return data as FragmentType<F>; | ||
} | ||
export function isFragmentReady<TQuery, TFrag>( | ||
queryNode: DocumentTypeDecoration<TQuery, any>, | ||
fragmentNode: TypedDocumentNode<TFrag>, | ||
data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined | ||
): data is FragmentType<typeof fragmentNode> { | ||
const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__ | ||
?.deferredFields; | ||
|
||
if (!deferredFields) return true; | ||
|
||
const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined; | ||
const fragName = fragDef?.name?.value; | ||
|
||
const fields = (fragName && deferredFields[fragName]) || []; | ||
return fields.length > 0 && fields.every(field => data && field in data); | ||
} |
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,290 @@ | ||
import { gql } from '@apollo/client'; | ||
import * as Apollo from '@apollo/client'; | ||
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]> }; | ||
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never }; | ||
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never }; | ||
const defaultOptions = {} as const; | ||
/** All built-in and custom scalars, mapped to their actual values */ | ||
export type Scalars = { | ||
ID: { input: string; output: string; } | ||
String: { input: string; output: string; } | ||
Boolean: { input: boolean; output: boolean; } | ||
Int: { input: number; output: number; } | ||
Float: { input: number; output: number; } | ||
}; | ||
|
||
export type Manager = { | ||
__typename?: 'Manager'; | ||
Id: Scalars['Int']['output']; | ||
Name: Scalars['String']['output']; | ||
Reports: ReportConnection; | ||
}; | ||
|
||
|
||
export type ManagerReportsArgs = { | ||
after?: InputMaybe<Scalars['String']['input']>; | ||
before?: InputMaybe<Scalars['String']['input']>; | ||
first?: InputMaybe<Scalars['Int']['input']>; | ||
last?: InputMaybe<Scalars['Int']['input']>; | ||
}; | ||
|
||
/** The connection type for Manager. */ | ||
export type ManagerConnection = { | ||
__typename?: 'ManagerConnection'; | ||
/** A list of edges. */ | ||
edges?: Maybe<Array<Maybe<ManagerEdge>>>; | ||
/** A list of nodes. */ | ||
nodes?: Maybe<Array<Maybe<Manager>>>; | ||
/** Information to aid in pagination. */ | ||
pageInfo: PageInfo; | ||
}; | ||
|
||
/** Autogenerated input type of ManagerCreate */ | ||
export type ManagerCreateInput = { | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: InputMaybe<Scalars['String']['input']>; | ||
managerInput: ManagerInput; | ||
}; | ||
|
||
/** Autogenerated return type of ManagerCreate. */ | ||
export type ManagerCreatePayload = { | ||
__typename?: 'ManagerCreatePayload'; | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: Maybe<Scalars['String']['output']>; | ||
manager: Manager; | ||
}; | ||
|
||
/** An edge in a connection. */ | ||
export type ManagerEdge = { | ||
__typename?: 'ManagerEdge'; | ||
/** A cursor for use in pagination. */ | ||
cursor: Scalars['String']['output']; | ||
/** The item at the end of the edge. */ | ||
node?: Maybe<Manager>; | ||
}; | ||
|
||
export type ManagerInput = { | ||
Id: Scalars['Int']['input']; | ||
Name: Scalars['String']['input']; | ||
}; | ||
|
||
/** Autogenerated input type of ManagerUpdate */ | ||
export type ManagerUpdateInput = { | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: InputMaybe<Scalars['String']['input']>; | ||
id: Scalars['ID']['input']; | ||
managerInput: ManagerInput; | ||
}; | ||
|
||
/** Autogenerated return type of ManagerUpdate. */ | ||
export type ManagerUpdatePayload = { | ||
__typename?: 'ManagerUpdatePayload'; | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: Maybe<Scalars['String']['output']>; | ||
manager: Manager; | ||
}; | ||
|
||
export type Mutation = { | ||
__typename?: 'Mutation'; | ||
/** Creates a new manager */ | ||
managerCreate?: Maybe<ManagerCreatePayload>; | ||
/** Updates a manager by id */ | ||
managerUpdate?: Maybe<ManagerUpdatePayload>; | ||
/** Creates a new report */ | ||
reportCreate?: Maybe<ReportCreatePayload>; | ||
/** Updates a report by id */ | ||
reportUpdate?: Maybe<ReportUpdatePayload>; | ||
}; | ||
|
||
|
||
export type MutationManagerCreateArgs = { | ||
input: ManagerCreateInput; | ||
}; | ||
|
||
|
||
export type MutationManagerUpdateArgs = { | ||
input: ManagerUpdateInput; | ||
}; | ||
|
||
|
||
export type MutationReportCreateArgs = { | ||
input: ReportCreateInput; | ||
}; | ||
|
||
|
||
export type MutationReportUpdateArgs = { | ||
input: ReportUpdateInput; | ||
}; | ||
|
||
/** Fields to order by and the sort direction */ | ||
export type Order = { | ||
direction: Scalars['String']['input']; | ||
field: Scalars['String']['input']; | ||
}; | ||
|
||
/** Information about pagination in a connection. */ | ||
export type PageInfo = { | ||
__typename?: 'PageInfo'; | ||
/** When paginating forwards, the cursor to continue. */ | ||
endCursor?: Maybe<Scalars['String']['output']>; | ||
/** When paginating forwards, are there more items? */ | ||
hasNextPage: Scalars['Boolean']['output']; | ||
/** When paginating backwards, are there more items? */ | ||
hasPreviousPage: Scalars['Boolean']['output']; | ||
/** When paginating backwards, the cursor to continue. */ | ||
startCursor?: Maybe<Scalars['String']['output']>; | ||
}; | ||
|
||
export enum PerformanceCategory { | ||
HighPositive = 'HIGH_POSITIVE', | ||
New = 'NEW', | ||
OffTrack = 'OFF_TRACK', | ||
Positive = 'POSITIVE', | ||
UsuallyMeets = 'USUALLY_MEETS' | ||
} | ||
|
||
export type Query = { | ||
__typename?: 'Query'; | ||
/** Returns a list of managers */ | ||
managers: ManagerConnection; | ||
/** Returns a list of reports */ | ||
reports: ReportConnection; | ||
}; | ||
|
||
|
||
export type QueryManagersArgs = { | ||
after?: InputMaybe<Scalars['String']['input']>; | ||
before?: InputMaybe<Scalars['String']['input']>; | ||
first?: InputMaybe<Scalars['Int']['input']>; | ||
last?: InputMaybe<Scalars['Int']['input']>; | ||
orderBy?: InputMaybe<Array<Order>>; | ||
}; | ||
|
||
|
||
export type QueryReportsArgs = { | ||
after?: InputMaybe<Scalars['String']['input']>; | ||
before?: InputMaybe<Scalars['String']['input']>; | ||
first?: InputMaybe<Scalars['Int']['input']>; | ||
last?: InputMaybe<Scalars['Int']['input']>; | ||
}; | ||
|
||
export type Report = { | ||
__typename?: 'Report'; | ||
Id: Scalars['Int']['output']; | ||
Manager: Manager; | ||
ManagerId: Scalars['Int']['output']; | ||
Name: Scalars['String']['output']; | ||
Performance: PerformanceCategory; | ||
}; | ||
|
||
/** The connection type for Report. */ | ||
export type ReportConnection = { | ||
__typename?: 'ReportConnection'; | ||
/** A list of edges. */ | ||
edges?: Maybe<Array<Maybe<ReportEdge>>>; | ||
/** A list of nodes. */ | ||
nodes?: Maybe<Array<Maybe<Report>>>; | ||
/** Information to aid in pagination. */ | ||
pageInfo: PageInfo; | ||
}; | ||
|
||
/** Autogenerated input type of ReportCreate */ | ||
export type ReportCreateInput = { | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: InputMaybe<Scalars['String']['input']>; | ||
reportInput: ReportInput; | ||
}; | ||
|
||
/** Autogenerated return type of ReportCreate. */ | ||
export type ReportCreatePayload = { | ||
__typename?: 'ReportCreatePayload'; | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: Maybe<Scalars['String']['output']>; | ||
report: Report; | ||
}; | ||
|
||
/** An edge in a connection. */ | ||
export type ReportEdge = { | ||
__typename?: 'ReportEdge'; | ||
/** A cursor for use in pagination. */ | ||
cursor: Scalars['String']['output']; | ||
/** The item at the end of the edge. */ | ||
node?: Maybe<Report>; | ||
}; | ||
|
||
export type ReportInput = { | ||
Id: Scalars['Int']['input']; | ||
ManagerId: Scalars['Int']['input']; | ||
Name: Scalars['String']['input']; | ||
Performance: PerformanceCategory; | ||
}; | ||
|
||
/** Autogenerated input type of ReportUpdate */ | ||
export type ReportUpdateInput = { | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: InputMaybe<Scalars['String']['input']>; | ||
id: Scalars['ID']['input']; | ||
reportInput: ReportInput; | ||
}; | ||
|
||
/** Autogenerated return type of ReportUpdate. */ | ||
export type ReportUpdatePayload = { | ||
__typename?: 'ReportUpdatePayload'; | ||
/** A unique identifier for the client performing the mutation. */ | ||
clientMutationId?: Maybe<Scalars['String']['output']>; | ||
report: Report; | ||
}; | ||
|
||
export type ManagersQueryVariables = Exact<{ [key: string]: never; }>; | ||
|
||
|
||
export type ManagersQuery = { __typename?: 'Query', managers: { __typename?: 'ManagerConnection', nodes?: Array<{ __typename?: 'Manager', id: number, name: string, reports: { __typename?: 'ReportConnection', nodes?: Array<{ __typename?: 'Report', id: number, name: string } | null> | null } } | null> | null } }; | ||
|
||
|
||
export const ManagersDocument = gql` | ||
query managers { | ||
managers(first: 10, orderBy: {field: "name", direction: "ASC"}) { | ||
nodes { | ||
id: Id | ||
name: Name | ||
reports: Reports { | ||
nodes { | ||
id: Id | ||
name: Name | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
/** | ||
* __useManagersQuery__ | ||
* | ||
* To run a query within a React component, call `useManagersQuery` and pass it any options that fit your needs. | ||
* When your component renders, `useManagersQuery` returns an object from Apollo Client that contains loading, error, and data properties | ||
* you can use to render your UI. | ||
* | ||
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; | ||
* | ||
* @example | ||
* const { data, loading, error } = useManagersQuery({ | ||
* variables: { | ||
* }, | ||
* }); | ||
*/ | ||
export function useManagersQuery(baseOptions?: Apollo.QueryHookOptions<ManagersQuery, ManagersQueryVariables>) { | ||
const options = {...defaultOptions, ...baseOptions} | ||
return Apollo.useQuery<ManagersQuery, ManagersQueryVariables>(ManagersDocument, options); | ||
} | ||
export function useManagersLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ManagersQuery, ManagersQueryVariables>) { | ||
const options = {...defaultOptions, ...baseOptions} | ||
return Apollo.useLazyQuery<ManagersQuery, ManagersQueryVariables>(ManagersDocument, options); | ||
} | ||
export type ManagersQueryHookResult = ReturnType<typeof useManagersQuery>; | ||
export type ManagersLazyQueryHookResult = ReturnType<typeof useManagersLazyQuery>; | ||
export type ManagersQueryResult = Apollo.QueryResult<ManagersQuery, ManagersQueryVariables>; |
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 @@ | ||
export * from "./fragment-masking"; |