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

Add directives support to Interfaces #744

Merged
merged 3 commits into from
Jan 4, 2021

Conversation

Superd22
Copy link
Contributor

This PR adds support for using @Directive on InterfaceType (and its fields).

Directives are supported on interface as per GraphQL specs and that support is widely implemented, see Apollo for example.

Possible caveats

In this proposed implementation, any ObjectType implementing the interface (more precisely, whose typescript class extends the typescript class of the interface) will inherit its directives. This seems in line with the current behavior of TypeGraphQL.
Nevertheless, as it stands, users would not be able to only add directive to the interface and not the objects implementing it.

I'd love insights about this behavior and if you think that's a problem.

@codecov
Copy link

codecov bot commented Oct 31, 2020

Codecov Report

Merging #744 (8bfb3b6) into master (8d8bbae) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #744   +/-   ##
=======================================
  Coverage   95.34%   95.35%           
=======================================
  Files          80       80           
  Lines        1483     1485    +2     
  Branches      295      295           
=======================================
+ Hits         1414     1416    +2     
  Misses         66       66           
  Partials        3        3           
Impacted Files Coverage Δ
src/schema/definition-node.ts 92.50% <100.00%> (+0.83%) ⬆️
src/schema/schema-generator.ts 97.68% <100.00%> (+<0.01%) ⬆️
src/resolvers/create.ts 96.72% <0.00%> (ø)
src/resolvers/helpers.ts 100.00% <0.00%> (ø)
src/helpers/auth-middleware.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d8bbae...5c1a25a. Read the comment docs.

@MichalLytek MichalLytek self-requested a review November 18, 2020 12:30
@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request labels Nov 18, 2020
@MichalLytek MichalLytek added this to the 1.x versions milestone Nov 18, 2020
@MichalLytek
Copy link
Owner

Sorry @Superd22 for no response for this PR for over 2 months, I've totally forgot about this 😞

users would not be able to only add directive to the interface and not the objects implementing it

I think that's ok. If there will be some use cases for separating interfaces from object types, we can always add some global or scoped config for that 😉

Copy link
Owner

@MichalLytek MichalLytek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! ❤️

@MichalLytek MichalLytek force-pushed the feat-interface-directives branch from 8bfb3b6 to 5c1a25a Compare January 4, 2021 19:53
@MichalLytek
Copy link
Owner

I've added changelog entry and updated docs 😉 Merging 🚀

@MichalLytek MichalLytek merged commit d1a67a7 into MichalLytek:master Jan 4, 2021
MichalLytek added a commit that referenced this pull request Jan 4, 2021
Co-authored-by: Michał Lytek <michal.wojciech.lytek@gmail.com>
@MichalLytek MichalLytek modified the milestones: 1.x versions, 1.2 Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants