Skip to content

Instantly share code, notes, and snippets.

@mattiamanzati
Created October 31, 2017 14:32
Show Gist options
  • Save mattiamanzati/e9832cfe54ad512e0318875291c642af to your computer and use it in GitHub Desktop.
Save mattiamanzati/e9832cfe54ad512e0318875291c642af to your computer and use it in GitHub Desktop.
extend type Order {
pay(id: ID!, amount: Float!): Boolean
}
/**
* _______________________________________
* / This file is automatically generated by \
* | sfat CLI! You must not manually modify |
* | this file, modify the source and |
* \ recompile instead. /
* ---------------------------------------
* \ ^__^
* \ (oo)\_______
* (__)\ )\/\
* ||----w |
* || ||
*/
import { IObservableArray } from "mobx";
import { IStateTreeNode, IModelType, types as t, flow } from "mobx-state-tree";
import { Order, IOrder } from "gendux-stack-router";
// utility code
export type I$Order$pay$args = { id: string; amount: number };
export type I$Order$pay = {
args: I$Order$pay$args;
self: IOrder;
context: IQuery & IMutation;
};
// compiled interface
declare module "gendux-stack-router/lib/types/Todo.graphql" {
export interface IOrder {
pay(args: I$Order$pay$args): Promise<boolean | null>;
}
}
// compiled models
// register the module
declare function entity<T>(...args: any[]): IModelType<any, T>;
export default function(context: any) {
context.extend(Order, (base: any) =>
base.props({}).actions((self: any) => ({}))
);
}
type User {
id: ID!
# A sample field
email: String!
test: [Int]!
name: String!
stripeCustomerId: String
password: String!
orders: [Order!]!
}
type Order {
id: ID!
description: String!
user: User!
}
/**
* _______________________________________
* / This file is automatically generated by \
* | sfat CLI! You must not manually modify |
* | this file, modify the source and |
* \ recompile instead. /
* ---------------------------------------
* \ ^__^
* \ (oo)\_______
* (__)\ )\/\
* ||----w |
* || ||
*/
import { IObservableArray } from "mobx";
import { IStateTreeNode, IModelType, types as t, flow } from "mobx-state-tree";
// utility code
// compiled interface
export interface IUser {
id: string;
email: string;
test: IObservableArray<number | null> & IStateTreeNode;
name: string;
stripeCustomerId: string | null;
password: string;
orders: IObservableArray<IOrder & IStateTreeNode> & IStateTreeNode;
}
export interface IOrder {
id: string;
description: string;
user: IUser & IStateTreeNode;
}
// compiled models
export const User = entity<IUser>("User", (base: any) =>
base
.props({
id: t.identifier(t.string),
email: t.string,
test: t.array(t.maybe(t.refinement("Int", t.number, n => n % 1 === 0))),
name: t.string,
stripeCustomerId: t.maybe(t.string),
password: t.string,
orders: t.array(t.late<any, IOrder>(() => Order))
})
.actions((self: any) => ({}))
);
export const Order = entity<IOrder>("Order", (base: any) =>
base
.props({
id: t.identifier(t.string),
description: t.string,
user: t.late<any, IUser>(() => User)
})
.actions((self: any) => ({}))
);
// register the module
declare function entity<T>(...args: any[]): IModelType<any, T>;
export default function(context: any) {
context.register(User);
context.register(Order);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment