Skip to content

Add WebGraphQlRequest constructor #681

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

Closed
wants to merge 1 commit into from

Conversation

nkonev
Copy link

@nkonev nkonev commented Apr 27, 2023

With direct passing query, operationName, variables. It will help to create multipart GraphQlHttpHandler

It is small part of #430 which will help to create multipart GraphQlHttpHandler

With direct passing query, operationName, variables. It will help to create multipart GraphQlHttpHandler
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 27, 2023
@rstoyanchev rstoyanchev self-assigned this Apr 28, 2023
@rstoyanchev rstoyanchev added this to the 1.2.0 milestone Apr 28, 2023
@rstoyanchev rstoyanchev added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 28, 2023
@rstoyanchev
Copy link
Contributor

Given the existing constructor takes a Map, couldn't you do this over here:

Map<String, Object> body = Map.of(
		"query", query, "operationName", opName, "variables", queryVariables, "extensions", extensions);

WebGraphQlRequest graphQlRequest = new WebGraphQlRequest(
		serverRequest.uri(), serverRequest.headers().asHttpHeaders(),
		body,
		serverRequest.exchange().getRequest().getId(),
		serverRequest.exchange().getLocaleContext().getLocale());

Or otherwise the existing constructor becomes a simple delegation to the new one, but looking at the above I'm not sure it really helps that much.

@nkonev
Copy link
Author

nkonev commented Apr 28, 2023

Yes, thank you, it looks workable

        Map<String, Object> body = Map.of(
                "query", query, "operationName", StringUtils.hasText(opName) ? opName : "", "variables", queryVariables, "extensions", extensions);

        WebGraphQlRequest graphQlRequest = new WebGraphQlRequest(
			serverRequest.uri(), serverRequest.headers().asHttpHeaders(), body,
			this.idGenerator.generateId().toString(), LocaleContextHolder.getLocale());

@nkonev nkonev closed this Apr 28, 2023
@rstoyanchev rstoyanchev removed this from the 1.2.0 milestone May 2, 2023
@rstoyanchev rstoyanchev added the status: declined A suggestion or change that we don't feel we should currently apply label May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants