Skip to content

Commit

Permalink
add some test types
Browse files Browse the repository at this point in the history
Signed-off-by: James Phillips <[email protected]>
  • Loading branch information
jamesdphillips committed Jan 11, 2018
1 parent 5401838 commit 4e6a5ac
Show file tree
Hide file tree
Showing 8 changed files with 719 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ indent_size = 2
[*.proto]
indent_style = space
indent_size = 2

[*.graphql]
indent_style = space
indent_size = 2
14 changes: 4 additions & 10 deletions backend/apid/graphql/generator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ func genOutputTypeReference(t ast.Type) *jen.Statement {
}

func genTypeReference(t ast.Type, expectedType string) *jen.Statement {
var wrapperType ast.Type
var namedType *ast.Named
switch ttype := t.(type) {
case *ast.List:
wrapperType = ttype
namedType = ttype.Type.(*ast.Named)
s := genTypeReference(ttype.Type, expectedType)
return jen.Qual(graphqlPkg, "NewList").Call(s)
case *ast.NonNull:
wrapperType = t
namedType = ttype.Type.(*ast.Named)
s := genTypeReference(ttype.Type, expectedType)
return jen.Qual(graphqlPkg, "NewNonNull").Call(s)
case *ast.Named:
namedType = ttype
default:
Expand All @@ -54,10 +53,5 @@ func genTypeReference(t ast.Type, expectedType string) *jen.Statement {
valueStatement = jen.Qual(utilPkg, expectedType).Call(jen.Lit(name))
}

if _, ok := wrapperType.(*ast.NonNull); ok {
return jen.Qual(graphqlPkg, "NewNonNull").Call(valueStatement)
} else if _, ok := wrapperType.(*ast.List); ok {
return jen.Qual(graphqlPkg, "NewList").Call(valueStatement)
}
return valueStatement
}
237 changes: 237 additions & 0 deletions backend/apid/graphql/schema/mutations.gql.go

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

30 changes: 30 additions & 0 deletions backend/apid/graphql/schema/mutations.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
The root query for implementing GraphQL mutations.
"""
type Mutation {
"Creates a new check."
createCheck(input: CreateCheckInput!): CreateCheckPayload
}

#
# CreateCheckMutation
#

input CreateCheckInput {
"A unique identifier for the client performing the mutation."
clientMutationId: String

"namespace the resulting resource will belong to"
ns: Namespace = {organization: "default", environment: "default"}

name: String!
command: String!
}

type CreateCheckPayload {
"A unique identifier for the client performing the mutation."
clientMutationId: String

"The new check."
check: Check!
}
Loading

0 comments on commit 4e6a5ac

Please sign in to comment.