Skip to content

Instantly share code, notes, and snippets.

@gsans
Last active August 22, 2019 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsans/5757dfd1cc199485c8a047177482ed9b to your computer and use it in GitHub Desktop.
Save gsans/5757dfd1cc199485c8a047177482ed9b to your computer and use it in GitHub Desktop.
API.ts
/* tslint:disable */
// This file was automatically generated and should not be edited.
import { Injectable } from "@angular/core";
import API, { graphqlOperation } from "@aws-amplify/api";
import { GraphQLResult } from "@aws-amplify/api/lib/types";
import * as Observable from "zen-observable";
export type CreateRestaurantInput = {
id?: string | null;
clientId?: string | null;
name: string;
description: string;
city: string;
};
export type UpdateRestaurantInput = {
id: string;
clientId?: string | null;
name?: string | null;
description?: string | null;
city?: string | null;
};
export type DeleteRestaurantInput = {
id?: string | null;
};
export type ModelRestaurantFilterInput = {
id?: ModelIDFilterInput | null;
clientId?: ModelStringFilterInput | null;
name?: ModelStringFilterInput | null;
description?: ModelStringFilterInput | null;
city?: ModelStringFilterInput | null;
and?: Array<ModelRestaurantFilterInput | null> | null;
or?: Array<ModelRestaurantFilterInput | null> | null;
not?: ModelRestaurantFilterInput | null;
};
export type ModelIDFilterInput = {
ne?: string | null;
eq?: string | null;
le?: string | null;
lt?: string | null;
ge?: string | null;
gt?: string | null;
contains?: string | null;
notContains?: string | null;
between?: Array<string | null> | null;
beginsWith?: string | null;
};
export type ModelStringFilterInput = {
ne?: string | null;
eq?: string | null;
le?: string | null;
lt?: string | null;
ge?: string | null;
gt?: string | null;
contains?: string | null;
notContains?: string | null;
between?: Array<string | null> | null;
beginsWith?: string | null;
};
export type CreateRestaurantMutation = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
export type UpdateRestaurantMutation = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
export type DeleteRestaurantMutation = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
export type GetRestaurantQuery = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
export type ListRestaurantsQuery = {
__typename: "ModelRestaurantConnection";
items: Array<{
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
} | null> | null;
nextToken: string | null;
};
export type OnCreateRestaurantSubscription = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
export type OnUpdateRestaurantSubscription = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
export type OnDeleteRestaurantSubscription = {
__typename: "Restaurant";
id: string;
clientId: string | null;
name: string;
description: string;
city: string;
};
@Injectable({
providedIn: "root"
})
export class APIService {
async CreateRestaurant(
input: CreateRestaurantInput
): Promise<CreateRestaurantMutation> {
const statement = `mutation CreateRestaurant($input: CreateRestaurantInput!) {
createRestaurant(input: $input) {
__typename
id
clientId
name
description
city
}
}`;
const gqlAPIServiceArguments: any = {
input
};
const response = (await API.graphql(
graphqlOperation(statement, gqlAPIServiceArguments)
)) as any;
return <CreateRestaurantMutation>response.data.createRestaurant;
}
async UpdateRestaurant(
input: UpdateRestaurantInput
): Promise<UpdateRestaurantMutation> {
const statement = `mutation UpdateRestaurant($input: UpdateRestaurantInput!) {
updateRestaurant(input: $input) {
__typename
id
clientId
name
description
city
}
}`;
const gqlAPIServiceArguments: any = {
input
};
const response = (await API.graphql(
graphqlOperation(statement, gqlAPIServiceArguments)
)) as any;
return <UpdateRestaurantMutation>response.data.updateRestaurant;
}
async DeleteRestaurant(
input: DeleteRestaurantInput
): Promise<DeleteRestaurantMutation> {
const statement = `mutation DeleteRestaurant($input: DeleteRestaurantInput!) {
deleteRestaurant(input: $input) {
__typename
id
clientId
name
description
city
}
}`;
const gqlAPIServiceArguments: any = {
input
};
const response = (await API.graphql(
graphqlOperation(statement, gqlAPIServiceArguments)
)) as any;
return <DeleteRestaurantMutation>response.data.deleteRestaurant;
}
async GetRestaurant(id: string): Promise<GetRestaurantQuery> {
const statement = `query GetRestaurant($id: ID!) {
getRestaurant(id: $id) {
__typename
id
clientId
name
description
city
}
}`;
const gqlAPIServiceArguments: any = {
id
};
const response = (await API.graphql(
graphqlOperation(statement, gqlAPIServiceArguments)
)) as any;
return <GetRestaurantQuery>response.data.getRestaurant;
}
async ListRestaurants(
filter?: ModelRestaurantFilterInput,
limit?: number,
nextToken?: string
): Promise<ListRestaurantsQuery> {
const statement = `query ListRestaurants($filter: ModelRestaurantFilterInput, $limit: Int, $nextToken: String) {
listRestaurants(filter: $filter, limit: $limit, nextToken: $nextToken) {
__typename
items {
__typename
id
clientId
name
description
city
}
nextToken
}
}`;
const gqlAPIServiceArguments: any = {};
if (filter) {
gqlAPIServiceArguments.filter = filter;
}
if (limit) {
gqlAPIServiceArguments.limit = limit;
}
if (nextToken) {
gqlAPIServiceArguments.nextToken = nextToken;
}
const response = (await API.graphql(
graphqlOperation(statement, gqlAPIServiceArguments)
)) as any;
return <ListRestaurantsQuery>response.data.listRestaurants;
}
OnCreateRestaurantListener: Observable<
OnCreateRestaurantSubscription
> = API.graphql(
graphqlOperation(
`subscription OnCreateRestaurant {
onCreateRestaurant {
__typename
id
clientId
name
description
city
}
}`
)
) as Observable<OnCreateRestaurantSubscription>;
OnUpdateRestaurantListener: Observable<
OnUpdateRestaurantSubscription
> = API.graphql(
graphqlOperation(
`subscription OnUpdateRestaurant {
onUpdateRestaurant {
__typename
id
clientId
name
description
city
}
}`
)
) as Observable<OnUpdateRestaurantSubscription>;
OnDeleteRestaurantListener: Observable<
OnDeleteRestaurantSubscription
> = API.graphql(
graphqlOperation(
`subscription OnDeleteRestaurant {
onDeleteRestaurant {
__typename
id
clientId
name
description
city
}
}`
)
) as Observable<OnDeleteRestaurantSubscription>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment