forked from Quramy/graphql-decorator
-
Notifications
You must be signed in to change notification settings - Fork 11
Feature - Refactoring more decorators #32
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,39 @@ | ||
| import { QueryOption, MutationOption, SubscriptionOption, EntryTypeOption } from '../metadata/options'; | ||
| import { EntryType } from '../metadata/args'; | ||
| import { getMetadataArgsStorage } from '../metadata-builder'; | ||
|
|
||
| /** | ||
| * It is used to create a root {@link GraphQLObjectType} object as a schema Query | ||
| * See [GraphQL Documentation - Queries and Mutations]{@http://graphql.org/learn/schema/#the-query-and-mutation-types} | ||
| */ | ||
| export function Query(option?: QueryOption) { | ||
| return entry(EntryType.Query, option); | ||
| } | ||
|
|
||
| /** | ||
| * It is used to create a root {@link GraphQLObjectType} object as a schema Mutation | ||
| * See [GraphQL Documentation - Queries and Mutations]{@http://graphql.org/learn/schema/#the-query-and-mutation-types} | ||
| */ | ||
| export function Mutation(option?: MutationOption) { | ||
| return entry(EntryType.Mutation, option); | ||
| } | ||
|
|
||
| /** | ||
| * It is used to create a root {@link GraphQLObjectType} object as a schema Subscription | ||
| * See [GraphQL Blog - Subscriptions in GraphQL and Relay]{@http://graphql.org/blog/subscriptions-in-graphql-and-relay/} | ||
| */ | ||
| export function Subscription(option?: SubscriptionOption) { | ||
| return entry(EntryType.Subscription, option); | ||
| } | ||
|
|
||
| function entry(type: EntryType, option?: EntryTypeOption) { | ||
| return function (target: any, propertyKey: any) { | ||
| getMetadataArgsStorage().entries.push({ | ||
| target: target, | ||
| name: target.name, | ||
| description: option ? option.description : null, | ||
| property: propertyKey, | ||
| type: type, | ||
| }); | ||
| }; | ||
| } |
This file contains hidden or 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,3 +1,6 @@ | ||
| export * from './enum-type.decorator'; | ||
| export * from './union-type.decorator'; | ||
| export * from './object-type.decorator'; | ||
| export * from './entry-type.decorator'; | ||
| export * from './schema.decorator'; | ||
| export * from './use-container.decorator'; |
This file contains hidden or 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,18 @@ | ||
| import { getMetadataArgsStorage } from '../metadata-builder'; | ||
| import { SchemaOption } from '../metadata'; | ||
|
|
||
| /** | ||
| * GraphQL Schema entry point | ||
| * See [GraphQL Documentation - Schema]{@link http://graphql.org/learn/schema/} | ||
| * | ||
| * @param option Options for an Schema | ||
| */ | ||
| export function Schema(option?: SchemaOption) { | ||
| return function (target: any) { | ||
| getMetadataArgsStorage().schemas.push({ | ||
| target: target, | ||
| name: target.name, | ||
| description: option ? option.description : null, | ||
| }); | ||
| } as Function; | ||
| } |
This file contains hidden or 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,11 @@ | ||
| import { IoCContainer } from '../ioc-container'; | ||
|
|
||
| /** | ||
| * Sets the IoC container to be used in order to instantiate the decorated class | ||
| * @param container a [typedi]{@link https://github.com/pleerock/typedi} container | ||
| */ | ||
| export function UseContainer(container: any) { | ||
| return function (target: Function) { | ||
| IoCContainer.INSTANCE = container; | ||
| }; | ||
| } |
This file contains hidden or 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 hidden or 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,4 +1,4 @@ | ||
| export * from './decorator'; | ||
| export { schemaFactory } from './schema_factory'; | ||
| export { schemaFactory } from './type-factory'; | ||
| export * from './order-by-item'; | ||
| export * from './pagination.type'; |
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
| export interface DefaultArg { | ||
| target: any; | ||
| name: string; | ||
| description?: string; | ||
| } |
This file contains hidden or 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,12 @@ | ||
| import { DefaultArg } from './default.arg'; | ||
|
|
||
| export enum EntryType { | ||
| Query = <any>'Query', | ||
| Mutation = <any>'Mutation', | ||
| Subscription = <any>'Subscription', | ||
| } | ||
|
|
||
| export interface EntryTypeArg extends DefaultArg { | ||
| type: EntryType; | ||
| property: string; | ||
| } |
This file contains hidden or 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,13 +1,8 @@ | ||
| export interface EnumTypeArg { | ||
| target: any; | ||
| name: string; | ||
| description?: string; | ||
| } | ||
| import { DefaultArg } from './default.arg'; | ||
|
|
||
| export interface EnumTypeArg extends DefaultArg { } | ||
|
|
||
| export interface EnumValueArg { | ||
| target: any; | ||
| name: string; | ||
| description?: string; | ||
| export interface EnumValueArg extends DefaultArg { | ||
| value: any; | ||
| } | ||
|
|
This file contains hidden or 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,3 +1,5 @@ | ||
| export * from './enum-type.arg'; | ||
| export * from './union-type.arg'; | ||
| export * from './object-type.arg'; | ||
| export * from './entry-type.arg'; | ||
| export * from './schema.arg'; |
This file contains hidden or 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,6 +1,5 @@ | ||
| export interface ObjectTypeArg { | ||
| target: any; | ||
| name: string; | ||
| description?: string; | ||
| import { DefaultArg } from './default.arg'; | ||
|
|
||
| export interface ObjectTypeArg extends DefaultArg { | ||
| isInput: boolean; | ||
| } |
This file contains hidden or 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,3 @@ | ||
| import { DefaultArg } from './default.arg'; | ||
|
|
||
| export interface SchemaArg extends DefaultArg { } |
This file contains hidden or 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,7 +1,6 @@ | ||
| export interface UnionTypeArgs { | ||
| target: any; | ||
| name: string; | ||
| import { DefaultArg } from './default.arg'; | ||
|
|
||
| export interface UnionTypeArg extends DefaultArg { | ||
| types: any[]; | ||
| description?: string; | ||
| resolver: (obj: any, context: any, info: any) => Promise<string> | string | null; | ||
| } |
This file contains hidden or 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,6 @@ | ||
| export interface DefaultOption { | ||
| /** | ||
| * (Optional) Description | ||
| */ | ||
| description?: string; | ||
| } | ||
This file contains hidden or 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,18 @@ | ||
| import { DefaultOption } from './default.option'; | ||
|
|
||
| export interface EntryTypeOption extends DefaultOption { } | ||
|
|
||
| /** | ||
| * Arguments for a {@link Query} type on graphql schema | ||
| */ | ||
| export interface QueryOption extends EntryTypeOption { } | ||
|
|
||
| /** | ||
| * Arguments for a {@link Mutation} type on graphql schema | ||
| */ | ||
| export interface MutationOption extends EntryTypeOption { } | ||
|
|
||
| /** | ||
| * Arguments for a {@link Subscription} type on graphql schema | ||
| */ | ||
| export interface SubscriptionOption extends EntryTypeOption { } |
This file contains hidden or 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,15 +1,11 @@ | ||
| import { DefaultOption } from './default.option'; | ||
|
|
||
| /** | ||
| * Arguments for an Enum type on graphql schema | ||
| */ | ||
| export interface EnumOption { | ||
| /** | ||
| * (Optional) Description | ||
| */ | ||
| description?: string; | ||
| } | ||
| export interface EnumOption extends DefaultOption { } | ||
|
|
||
| /** | ||
| * Arguments for an Enum value on graphql schema | ||
| */ | ||
| export interface EnumValueOption extends EnumOption { | ||
| } | ||
| export interface EnumValueOption extends DefaultOption { } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default or common? which one is preferable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about only
Option,MetadataandArginstead ofDefaultOption,DefaultMetadataandDefaultArg?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some progress in other refactoring and will do this in my upcoming refactor PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Done at ea05219