Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not writing the undefined operation types #47

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v0.2.12

- Fix where the undefined operation type is generated https://github.com/mununki/gqlmerge/pull/47

## v0.2.11

- Fixed mis-used rune `[` instead of tokLBracket https://github.com/mununki/gqlmerge/pull/41
Expand Down
2 changes: 1 addition & 1 deletion command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (c *Command) Check() error {
NotEnoughArgs: "❌ Not enough arguments",
OutputFileNeeded: "❌ Output file argument is needed",
WrongOption: "❌ Wrong options",
Version: "v0.2.11",
Version: "v0.2.12",
}

help := flag.Bool("h", false, "show the help")
Expand Down
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