-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Support for root field tags (#162) * Support for root field tags Right now the mechanism for defining root fields is just too cumbersome. It requires defining a type `type Query = unknown` is nonsensicle _and_ is part of the very first hello world. Additionally, it requires defining functions with unused initial arguments: ```typescript /** @gqlField */ export function greeting(_: Query): string { return "Hello"; } ``` This is confusing and nonsensicle, but also prevents these fields being reused for non-GraphQL use cases which goes aginst the goals of Grats, which includes lettting people expose thier _existing_ TypeScript code. This PR adds three new tags to let you define Query/Mutation/Subscription fields without needing to explictly define or reference these types. [ghstack-poisoned] * Update on "Support for root field tags" Right now the mechanism for defining root fields is just too cumbersome. It requires defining a type `type Query = unknown` is nonsensicle _and_ is part of the very first hello world. Additionally, it requires defining functions with unused initial arguments: ```typescript /** gqlField */ export function greeting(_: Query): string { return "Hello"; } ``` This is confusing and nonsensicle, but also prevents these fields being reused for non-GraphQL use cases which goes aginst the goals of Grats, which includes lettting people expose thier _existing_ TypeScript code. This PR adds three new tags to let you define Query/Mutation/Subscription fields without needing to explictly define or reference these types. [ghstack-poisoned] * Update on "Support for root field tags" Right now the mechanism for defining root fields is just too cumbersome. It requires defining a type `type Query = unknown` is nonsensicle _and_ is part of the very first hello world. Additionally, it requires defining functions with unused initial arguments: ```typescript /** gqlField */ export function greeting(_: Query): string { return "Hello"; } ``` This is confusing and nonsensicle, but also prevents these fields being reused for non-GraphQL use cases which goes against the goals of Grats, which includes lettting people expose their _existing_ TypeScript code. Now such fields can be defined using: ```typescript /** gqlQueryField */ export function greeting(): string { return "Hello"; } ``` This PR adds three new tags to let you define Query/Mutation/Subscription fields without needing to explictly define or reference these types. [ghstack-poisoned] * Clean up source in docs generated ts
- Loading branch information
1 parent
831703d
commit 237d72c
Showing
156 changed files
with
1,257 additions
and
939 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
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 |
---|---|---|
@@ -1,14 +1,7 @@ | ||
import IPerson from "./interfaces/IPerson"; | ||
import User from "./models/User"; | ||
|
||
/** @gqlType */ | ||
export type Query = unknown; | ||
|
||
/** @gqlField */ | ||
export function me(_: Query): User { | ||
return new User(); | ||
} | ||
/** @gqlField */ | ||
export function person(_: Query): IPerson { | ||
/** @gqlQueryField */ | ||
export function person(): IPerson { | ||
return new User(); | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import User from "../models/User"; | ||
|
||
/** @gqlInterface */ | ||
export default interface IPerson { | ||
/** @gqlField */ | ||
name(): string; | ||
} | ||
|
||
/** @gqlQueryField */ | ||
export function person(): IPerson { | ||
return new User(); | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import User from "../models/User"; | ||
|
||
/** @gqlInterface */ | ||
export default interface IPerson { | ||
/** @gqlField */ | ||
name(): string; | ||
} | ||
|
||
/** @gqlQueryField */ | ||
export function person(): IPerson { | ||
return new User(); | ||
} |
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
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
Oops, something went wrong.