-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
5,328 additions
and
397 deletions.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ts-gql/compiler": patch | ||
--- | ||
|
||
Inline some dependencies to reduce the size of the package |
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
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
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
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
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 |
---|---|---|
|
@@ -139,6 +139,7 @@ test("something", async () => { | |
`, | ||
graphql` | ||
query Thing { | ||
json | ||
someObj { | ||
arr { | ||
...Frag_a | ||
|
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 @@ | ||
These packages are inlined from https://github.com/dotansimha/graphql-code-generator, mainly to remove the dependency on relay-compiler which adds quite a large dependency tree |
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,32 @@ | ||
// https://github.com/sindresorhus/auto-bind/blob/5f9859a2c163a6567f0595b6268ef667c8248c6a/index.js | ||
const getAllProperties = (object: object) => { | ||
const properties = new Set<[Record<string, any>, string | symbol]>(); | ||
|
||
do { | ||
for (const key of Reflect.ownKeys(object)) { | ||
properties.add([object, key]); | ||
} | ||
} while ( | ||
(object = Reflect.getPrototypeOf(object)!) && | ||
object !== Object.prototype | ||
); | ||
|
||
return properties; | ||
}; | ||
|
||
export function autoBind<SelfType extends Record<string, any>>( | ||
self: SelfType | ||
): SelfType { | ||
for (const [object, key] of getAllProperties(self.constructor.prototype)) { | ||
if (key === "constructor") { | ||
continue; | ||
} | ||
|
||
const descriptor = Reflect.getOwnPropertyDescriptor(object, key); | ||
if (descriptor && typeof descriptor.value === "function") { | ||
(self as any)[key] = self[key as string].bind(self); | ||
} | ||
} | ||
|
||
return self; | ||
} |
File renamed without changes.
File renamed without changes.
206 changes: 206 additions & 0 deletions
206
packages/compiler/src/vendor/typescript-operations/config.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,206 @@ | ||
import { | ||
AvoidOptionalsConfig, | ||
RawDocumentsConfig, | ||
} from "../visitor-plugin-common"; | ||
|
||
/** | ||
* @description This plugin generates TypeScript types based on your GraphQLSchema _and_ your GraphQL operations and fragments. | ||
* It generates types for your GraphQL documents: Query, Mutation, Subscription and Fragment. | ||
* | ||
* Note: In most configurations, this plugin requires you to use `typescript as well, because it depends on its base types. | ||
*/ | ||
export interface TypeScriptDocumentsPluginConfig extends RawDocumentsConfig { | ||
/** | ||
* @description The [GraphQL spec](https://spec.graphql.org/draft/#sel-FAHjBJFCAACE_Gh7d) | ||
* allows arrays and a single primitive value for list input. This allows to | ||
* deactivate that behavior to only accept arrays instead of single values. If | ||
* set to `false`, the definition: `query foo(bar: [Int!]!): Foo` will output | ||
* `bar: Array<Int>` instead of `bar: Array<Int> | Int` for the variable part. | ||
* @default true | ||
* | ||
* @exampleMarkdown | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* arrayInputCoercion: false | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
*/ | ||
arrayInputCoercion?: boolean; | ||
/** | ||
* @description This will cause the generator to avoid using TypeScript optionals (`?`) on types, | ||
* so the following definition: `type A { myField: String }` will output `myField: Maybe<string>` | ||
* instead of `myField?: Maybe<string>`. | ||
* @default false | ||
* | ||
* @exampleMarkdown | ||
* ## Override all definition types | ||
* | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* avoidOptionals: true | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
* | ||
* ## Override only specific definition types | ||
* | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* avoidOptionals: { | ||
* field: true | ||
* inputValue: true | ||
* object: true | ||
* defaultValue: true | ||
* } | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
*/ | ||
avoidOptionals?: boolean | AvoidOptionalsConfig; | ||
/** | ||
* @description Generates immutable types by adding `readonly` to properties and uses `ReadonlyArray`. | ||
* @default false | ||
* | ||
* @exampleMarkdown | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* immutableTypes: true | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
*/ | ||
immutableTypes?: boolean; | ||
|
||
/** | ||
* @description Set to `true` in order to generate output without `export` modifier. | ||
* This is useful if you are generating `.d.ts` file and want it to be globally available. | ||
* @default false | ||
* | ||
* @exampleMarkdown | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* noExport: true | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
*/ | ||
noExport?: boolean; | ||
/** | ||
* @description Allow to override the type value of `Maybe`. | ||
* @default T | null | ||
* | ||
* @exampleMarkdown | ||
* ## Allow undefined | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* maybeValue: 'T | null | undefined' | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
* | ||
* ## Allow `null` in resolvers: | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* maybeValue: 'T extends PromiseLike<infer U> ? Promise<U | null> : T | null' | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
*/ | ||
maybeValue?: string; | ||
|
||
/** | ||
* @description Adds undefined as a possible type for query variables | ||
* @default false | ||
* | ||
* @exampleMarkdown | ||
* ```ts filename="codegen.ts" | ||
* import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
* | ||
* const config: CodegenConfig = { | ||
* // ... | ||
* generates: { | ||
* 'path/to/file.ts': { | ||
* plugins: ['typescript'], | ||
* config: { | ||
* allowUndefinedQueryVariables: true | ||
* }, | ||
* }, | ||
* }, | ||
* }; | ||
* export default config; | ||
* ``` | ||
*/ | ||
|
||
allowUndefinedQueryVariables?: boolean; | ||
} |
Oops, something went wrong.