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

feat: support config::Union type as input type #1990

Closed
meskill opened this issue May 20, 2024 · 3 comments · Fixed by #2221
Closed

feat: support config::Union type as input type #1990

meskill opened this issue May 20, 2024 · 3 comments · Fixed by #2221
Labels
state: inactive No current action needed/possible; issue fixed, out of scope, or superseded.

Comments

@meskill
Copy link
Contributor

meskill commented May 20, 2024

Proposal

Allow to use Union types both as output and input types.

How to

Union type doesn't have exact representation as input type.

Proposal suggests to represent union type as input types do next:

For every member of union type that are used as field's arg generate new multiple fields in parent object with arguments that use this member of union type. Field names will be different and arguments should not use union type name but name of the inner types. The inner types should be outputed as input types in sdl.

I.e. for

{
	"types": {
		"T1": {},
		"T2": {},
		"V1": {},
		"V2": {},
		"Query": {
			"fields": {
				"call": {
					"type": "String",
					"args": {
						"str": {
							"type": "String"
						},
						"u1": {
							"type": "U1"
						},
						"u2": {
							"type": "U2"
						}
					}
				}
			}
		}
	},
	"unions": {
		"U1": ["T1", "T2"],
		"U2": ["V1", "V2"]
	},
	"schema": {
		"query": "Query"
	}
}

generate following sdl:

input T1 {}
input T2 {}
input V1 {}
input V2 {}

type Query {
	callVar0Var0(str: String, u1: T1, u2: V1): String
	callVar0Var1(str: String, u1: T1, u2: V2): String
	callVar1Var0(str: String, u1: T2, u2: V1): String
	callVar1Var1(str: String, u1: T2, u2: V2): String
}

Another approaches

  • @oneof directive from draft spec - but this adds additional nesting for types that should be separated by unions and it's hard to handle it.
@meskill
Copy link
Contributor Author

meskill commented May 20, 2024

Implemented in #1992

Copy link

Action required: Issue inactive for 30 days.
Status update or closure in 7 days.

@github-actions github-actions bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Jun 19, 2024
Copy link

Issue closed after 7 days of inactivity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
@meskill meskill reopened this Jun 26, 2024
@meskill meskill closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: inactive No current action needed/possible; issue fixed, out of scope, or superseded.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant