Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for root field tags (#162) #163

Merged
merged 2 commits into from
Dec 16, 2024
Merged

Support for root field tags (#162) #163

merged 2 commits into from
Dec 16, 2024

Conversation

captbaritone
Copy link
Owner

@captbaritone captbaritone commented Dec 16, 2024

  • 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:

/** @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 letting people expose their existing TypeScript code.

Now such fields can be defined using:

/** gqlQueryField */
export function greeting(): string {
  return "Hello";
}

This PR adds three new tags to let you define Query/Mutation/Subscription fields without needing to explicitly define or reference these types.

* 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]
@captbaritone captbaritone marked this pull request as ready for review December 16, 2024 05:34
Copy link

netlify bot commented Dec 16, 2024

Deploy Preview for grats ready!

Name Link
🔨 Latest commit 82a5e25
🔍 Latest deploy log https://app.netlify.com/sites/grats/deploys/675fbcb47f213d0008aa161b
😎 Deploy Preview https://deploy-preview-163--grats.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@captbaritone captbaritone merged commit 237d72c into main Dec 16, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant