Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow fields that return root level definitions #2858

Merged
merged 3 commits into from
Dec 11, 2023

Conversation

teandresmith
Copy link
Contributor

This PR generates structs for root level definitions (Query, Mutation and Subscription) which would also allow fields that return a root level type. This should close #1200, #956 and #2763.

I updated a couple of the examples to test if fields that return the root definitions worked properly and I also modified one of the queries in the integration tests.

I have:

  • Added tests covering the bug / feature (see testing)
  • Updated any relevant documentation (see docs)

@coveralls
Copy link

coveralls commented Dec 10, 2023

Coverage Status

coverage: 75.892% (-0.007%) from 75.899%
when pulling 123a397 on teandresmith:master
into e080a96 on 99designs:master.

@StevenACoffman
Copy link
Collaborator

Hey, it looks like you need to run:

go generate ./... && cd _examples && go generate ./...

Otherwise the linting and one of the tests fails.

diff --git a/_examples/chat/generated.go b/_examples/chat/generated.go
index e08d5f15..3efd1cac 100644
--- a/_examples/chat/generated.go
+++ b/_examples/chat/generated.go
@@ -620,7 +620,6 @@ func (ec *executionContext) _Chatroom_subscription(ctx context.Context, field gr
 			ret = graphql.Null
 		}
 	}()
-	// is root
 	res := Subscription{}
 	fc.Result = res
 	return ec.marshalNSubscription2githubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx, field.Selections, res)
@@ -831,7 +830,6 @@ func (ec *executionContext) _Message_subscription(ctx context.Context, field gra
 			ret = graphql.Null
 		}
 	}()
-	// is root
 	res := &Subscription{}
 	fc.Result = res
 	return ec.marshalNSubscription2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋchatᚐSubscription(ctx, field.Selections, res)
diff --git a/integration/server/generated.go b/integration/server/generated.go
index d89a8539..bdad3ccb 100644
--- a/integration/server/generated.go
+++ b/integration/server/generated.go
@@ -1299,7 +1299,6 @@ func (ec *executionContext) _User_query(ctx context.Context, field graphql.Colle
 			ret = graphql.Null
 		}
 	}()
-	// is root
 	res := models.Query{}
 	fc.Result = res
 	return ec.marshalNQuery2githubᚗcomᚋ99designsᚋgqlgenᚋintegrationᚋserverᚋmodelsᚑgoᚐQuery(ctx, field.Selections, res)

@StevenACoffman StevenACoffman merged commit 42f6e39 into 99designs:master Dec 11, 2023
16 of 17 checks passed
@StevenACoffman
Copy link
Collaborator

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants