Skip to content

Commit

Permalink
feat(create): adds type
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Sep 14, 2019
1 parent 502c98b commit 08f7d4d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './service';
export * from './services';
export * from './schema';
export * from './scope';
export * from './type';
31 changes: 31 additions & 0 deletions src/create/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
CollectionTree,
InputRequest,
InputResponse,
InputError
} from '~/types';
import { collection } from './collection';

export function error(name: string, type: InputError): CollectionTree {
const tree = collection();
tree.types.error[name] = type;
return tree;
}

export function request(name: string, type: InputRequest): CollectionTree {
const tree = collection();
tree.types.request[name] = type;
return tree;
}

export function response(name: string, type: InputResponse): CollectionTree {
const tree = collection();
tree.types.response[name] = {
...type,
children: {
query: (type.children && type.children.query) || {},
subscription: (type.children && type.children.subscription) || {}
}
};
return tree;
}

0 comments on commit 08f7d4d

Please sign in to comment.