Skip to content

Commit

Permalink
Add adapter function for prepare schema type name (#103)
Browse files Browse the repository at this point in the history
* Add adapter function for prepare schema type name

* Use context instance instead function parameter

* Build
  • Loading branch information
TLDMain authored and phortx committed Jun 7, 2019
1 parent 6183216 commit 0a4f142
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/vuex-orm-graphql.es5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuex-orm-graphql.es5.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuex-orm-graphql.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/vuex-orm-graphql.umd.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/adapters/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ export default interface Adapter {

getFilterTypeName(model: Model): string;
getInputTypeName(model: Model, action?: string): string;

prepareSchemaTypeName(name: string): string;
}
4 changes: 4 additions & 0 deletions src/adapters/builtin/default-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ export default class DefaultAdapter implements Adapter {
getNameForPush(model: Model): string {
return `update${upcaseFirstLetter(model.singularName)}`;
}

prepareSchemaTypeName(name: string): string {
return upcaseFirstLetter(name);
}
}
2 changes: 1 addition & 1 deletion src/graphql/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class Schema {
}

public getType(name: string, allowNull: boolean = false): GraphQLType | null {
name = upcaseFirstLetter(name);
name = Context.getInstance().adapter.prepareSchemaTypeName(name);
const type = this.types.get(name);

if (!allowNull && !type) {
Expand Down

0 comments on commit 0a4f142

Please sign in to comment.