Skip to content

Commit

Permalink
not write the undefined operation types
Browse files Browse the repository at this point in the history
  • Loading branch information
mununki committed Dec 14, 2023
1 parent 2015ef4 commit 09d6d8b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 33 deletions.
39 changes: 18 additions & 21 deletions lib/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,25 @@ type MergedSchema struct {
}

func (ms *MergedSchema) WriteSchema(s *Schema) string {
ms.writeDescriptions(s.SchemaDefinitions[0].Descriptions, 0, true)
ms.buf.WriteString("schema {\n")
ms.addIndent(1)
if s.SchemaDefinitions[0].Query != nil {
ms.buf.WriteString("query: " + *s.SchemaDefinitions[0].Query + "\n")
} else {
ms.buf.WriteString("query: Query\n")
}
ms.addIndent(1)
if s.SchemaDefinitions[0].Mutation != nil {
ms.buf.WriteString("mutation: " + *s.SchemaDefinitions[0].Mutation + "\n")
} else {
ms.buf.WriteString("mutation: Mutation\n")
}
ms.addIndent(1)
if s.SchemaDefinitions[0].Subscription != nil {
ms.buf.WriteString("subscription: " + *s.SchemaDefinitions[0].Subscription + "\n")
} else {
ms.buf.WriteString("subscription: Subscription\n")
}
if (s.SchemaDefinitions[0].Query != nil) || (s.SchemaDefinitions[0].Mutation != nil) || (s.SchemaDefinitions[0].Subscription != nil) {
ms.writeDescriptions(s.SchemaDefinitions[0].Descriptions, 0, true)
ms.buf.WriteString("schema {\n")
ms.addIndent(1)

ms.buf.WriteString("}\n\n")
if s.SchemaDefinitions[0].Query != nil {
ms.buf.WriteString("query: " + *s.SchemaDefinitions[0].Query + "\n")
}
ms.addIndent(1)
if s.SchemaDefinitions[0].Mutation != nil {
ms.buf.WriteString("mutation: " + *s.SchemaDefinitions[0].Mutation + "\n")
}
ms.addIndent(1)
if s.SchemaDefinitions[0].Subscription != nil {
ms.buf.WriteString("subscription: " + *s.SchemaDefinitions[0].Subscription + "\n")
}

ms.buf.WriteString("}\n\n")
}

numOfDirs := len(s.DirectiveDefinitions)
if numOfDirs > 0 {
Expand Down
6 changes: 2 additions & 4 deletions test/arg_input/generated.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
mutation: Mutation
}

type Mutation {
createLogKo(input: CreateLogInput!): String!
Expand Down
3 changes: 1 addition & 2 deletions test/basic/generated.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
}

"""
TEST : Directive 1
Expand Down
6 changes: 0 additions & 6 deletions test/property_type/generated.graphql
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
schema {
query: Query
mutation: Mutation
subscription: Subscription
}

type SomePayload {
type: String!
someKey: String!
Expand Down

0 comments on commit 09d6d8b

Please sign in to comment.