Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Update to new GraphQL client interface
Browse files Browse the repository at this point in the history
Migrate to subscription and query methods and move .graphql files
under appropriate src/graphql subdirectories.
  • Loading branch information
David Dooling committed Apr 13, 2018
1 parent 068f9e8 commit 6239d27
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 17 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased][]

[Unreleased]: https://github.com/atomist/automation-seed-ts/compare/0.9.0...HEAD
[Unreleased]: https://github.com/atomist/automation-seed-ts/compare/0.10.0...HEAD

## [0.10.0][] - 2018-04-13

[0.10.0]: https://github.com/atomist/automation-seed-ts/compare/0.9.0...0.10.0

GraphQL release

### Changed

- Updated to use new GraphQL client interfaces

## [0.9.0][] - 2018-04-10

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atomist/automation-seed",
"version": "0.9.0",
"version": "0.10.0",
"description": "Atomist automation seed project",
"author": "Atomist",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/HelloAutomation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { hostname } from "os";
const pj: any = require(`${appRoot.path}/package.json`);

@CommandHandler("sends information about this automation back to channel", `hello ${pj.name.replace(/^@/, "")}`)
@Tags("hello")
@Tags("hello", "automation")
export class HelloAutomation implements HandleCommand {

public handle(ctx: HandlerContext): Promise<HandlerResult> {
Expand Down
6 changes: 4 additions & 2 deletions src/commands/HelloWorld.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ export class HelloWorld implements HandleCommand {
return Promise.resolve(Success);
}

return ctx.graphClient.executeQueryFromFile<Person.Query, Person.Variables>("../graphql/person",
{ teamId: ctx.teamId, slackUser: this.slackUser }, undefined, __dirname)
return ctx.graphClient.query<Person.Query, Person.Variables>({
name: "person",
variables: { teamId: ctx.teamId, slackUser: this.slackUser },
})
.then(result => {
if (result && result.ChatTeam && result.ChatTeam[0] && result.ChatTeam[0].members &&
result.ChatTeam[0].members[0] && result.ChatTeam[0].members[0].person) {
Expand Down
3 changes: 1 addition & 2 deletions src/events/NotifyOnPush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import {

import * as graphql from "../typings/types";

@EventHandler("notify repo channels when there is a push",
GraphQL.subscriptionFromFile("../graphql/push", __dirname))
@EventHandler("notify repo channels when there is a push", GraphQL.subscription("push"))
@Tags("push", "notification")
export class NotifyOnPush implements HandleEvent<graphql.PushWithRepo.Subscription> {

Expand Down
File renamed without changes.
File renamed without changes.
25 changes: 16 additions & 9 deletions test/commands/HelloWorldTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,25 @@ describe("HelloWorld", () => {
const teamId = "T79TH";
const forename = "Chancelor";
const surname = "Bennett";
const emptyResponse = Promise.resolve({
ChatTeam: [{
members: [],
}],
});

it("should extract sender person", async () => {
let responseMessage: string;
const ctx = {
graphClient: {
executeQueryFromFile(queryFile: string, params: Person.Variables): Promise<Person.Query> {
if (params.slackUser !== hello.slackUser || params.teamId !== teamId) {
return null;
query(opts: any): Promise<Person.Query> {
if (!opts.name || opts.name !== "person") {
return emptyResponse;
}
if (!opts.variables || opts.variables.slackUser !== hello.slackUser) {
return emptyResponse;
}
if (!opts.variables || opts.variables.teamId !== teamId) {
return emptyResponse;
}
return Promise.resolve({
ChatTeam: [{
Expand Down Expand Up @@ -74,12 +85,8 @@ describe("HelloWorld", () => {
let responseMessage: string;
const ctx = {
graphClient: {
executeQueryFromFile(queryFile: string, params: Person.Variables): Promise<Person.Query> {
return Promise.resolve({
ChatTeam: [{
members: [],
}],
});
query(opts: any): Promise<Person.Query> {
return emptyResponse;
},
},
messageClient: {
Expand Down

0 comments on commit 6239d27

Please sign in to comment.