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

Allow sharing of type-names between queries. #48

Closed
csilvers opened this issue Aug 16, 2021 · 3 comments
Closed

Allow sharing of type-names between queries. #48

csilvers opened this issue Aug 16, 2021 · 3 comments

Comments

@csilvers
Copy link
Member

We have two different gql queries:

	_ = `# @genqlient
	query TestPrep_GetAssessmentItemsByShas($exerciseID: String!, $shas: [String!]!) {
	  assessmentItemsByShas(exerciseId: $exerciseID, shas: $shas) {
	    contentId
	    itemData
	    itemShapeType
	    name
	    sha
	    tagIds
	  }
	}`

	_ = `# @genqlient
	query TestPrep_GetAssessmentItemsForExercise($exerciseID: String!) {
	  exerciseById(id: $exerciseID) {
		assessmentItems {
	      contentId
	      itemData
	      itemShapeType
	      name
	      sha
	      tagIds
	    }
	  }
	}`

While the graphql queries differ, the "return" type is the same. It would be convenient if they could both be the same type in genqlient, rather than two different types with identical shapes.

This is probably related to #12.

@benjaminjkraft
Copy link
Collaborator

Good idea! This would need to be opt-in, I think, since it does make those types less stable (if you change one of the queries, say). But #12 is naturally opt-in, so it would make a lot of sense for them to go together.

@benjaminjkraft
Copy link
Collaborator

Ah, another option for how to do this would be via fragments; if you define a shared fragment, and spread that into all the queries, then genqlient can notice that and share the type. This is natural because then the queries actually guarantee that the types match. But of course it depends on #8.

@benjaminjkraft
Copy link
Collaborator

Ok, I think #8 (implemented) and/or #12 (in progress) will cover this!

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

No branches or pull requests

2 participants