MichalLytek / MichalLytek/type-graphql

Schema directives support

Open
#77 32 comments 36 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Blocked :no_entry_sign: Discussion :speech_balloon: Enhancement :new:
Dominant language
TypeScript
Stars
8.1k
Forks
672
PR merge metrics
No merged PRs in 30d

Description

## Partially solved by https://github.com/MichalLytek/type-graphql/pull/369

### Currently blocked by https://github.com/graphql/graphql-js/issues/1343

---

Ability to define any arbitrary graphql directive to be passed to the compiled schema:

```ts
@ObjectType({ directives: ['@cacheControl(maxAge: 240)'] })
class SampleObject {
// ...
}
```

Which should be equivalent to:
```graphql
type SampleObject @cacheControl(maxAge: 240) {
# ...
}
```

It might be also implemented as a separate decorator that would make possible to create custom decorators like `@CacheControl({ maxAge: 240 })`:
```ts
@Directive('@cacheControl(maxAge: 240)')
@ObjectType()
class SampleObject {
// ...
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with PR #369 and graphql/graphql-js issue #1343; they identify the existing partial work and external blocker. Once unblocked, completion means supporting arbitrary directives on the compiled schema, including the illustrated ObjectType option or Directive decorator behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.