-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from Phoenix-Commerce/feat/extend-app-through-…
…plugins feat: extend models and resolvers through plugins
- Loading branch information
Showing
20 changed files
with
396 additions
and
111 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#-------------------------------------------------------------------------------# | ||
# Qodana analysis is configured by qodana.yaml file # | ||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html # | ||
#-------------------------------------------------------------------------------# | ||
version: "1.0" | ||
|
||
#Specify inspection profile for code analysis | ||
profile: | ||
name: qodana.starter | ||
|
||
#Enable inspections | ||
#include: | ||
# - name: <SomeEnabledInspectionId> | ||
|
||
#Disable inspections | ||
#exclude: | ||
# - name: <SomeDisabledInspectionId> | ||
# paths: | ||
# - <path/where/not/run/inspection> | ||
|
||
#Execute shell command before Qodana execution (Applied in CI/CD pipeline) | ||
#bootstrap: sh ./prepare-qodana.sh | ||
|
||
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) | ||
#plugins: | ||
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com) | ||
|
||
#Specify Qodana linter for analysis (Applied in CI/CD pipeline) | ||
linter: jetbrains/qodana-js:latest |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Container } from 'typedi'; | ||
import { getModelForClass } from '@typegoose/typegoose'; | ||
import { type GlobalContext } from '../global-context'; | ||
import { Cart } from './models/cart'; | ||
import { CartResolver } from './resolvers/cart-resolver'; | ||
|
||
export default { | ||
name: 'cart-plugin', | ||
type: 'cart', | ||
resolvers: [CartResolver], | ||
register(container: typeof Container, context: GlobalContext) { | ||
const CartModel = getModelForClass(Cart); | ||
context.models['Cart'] = { schema: CartModel.schema, model: CartModel }; | ||
container.set('CartModel', CartModel); | ||
container.set(CartResolver, new CartResolver()); // Register CartResolver explicitly | ||
context.extendResolvers('Cart', [CartResolver]); | ||
const resolverMethods = Object.getOwnPropertyNames(CartResolver.prototype).filter( | ||
(method) => method !== 'constructor', | ||
); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Field, Float, Int, ObjectType } from 'type-graphql'; | ||
import { prop, getModelForClass } from '@typegoose/typegoose'; | ||
|
||
@ObjectType() | ||
export class Item { | ||
@Field() | ||
@prop({ required: true }) | ||
public name!: string; | ||
|
||
@Field() | ||
@prop({ required: true }) | ||
public description!: string; | ||
|
||
@Field() | ||
@prop({ required: true }) | ||
public productId!: string; | ||
|
||
@Field(() => Int) | ||
@prop({ required: true }) | ||
public quantity!: number; | ||
|
||
@Field(() => Float) | ||
@prop({ required: true }) | ||
public price!: number; | ||
} | ||
|
||
@ObjectType() | ||
export class Cart { | ||
@Field(() => [Item]) | ||
@prop({ type: () => [Item], default: [] }) | ||
public items: Item[] | undefined; | ||
} | ||
|
||
export const CartModel = getModelForClass(Cart); |
Oops, something went wrong.