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

baseUrl, error in the client when enabling S3 provider #1

Closed
Twathik opened this issue Feb 12, 2022 · 4 comments
Closed

baseUrl, error in the client when enabling S3 provider #1

Twathik opened this issue Feb 12, 2022 · 4 comments

Comments

@Twathik
Copy link

Twathik commented Feb 12, 2022

hello
Congratulation for this excellent project, il really look forward to try it out in production

For now I'am testing it a little, and I have somme issues

first, I'am using Traefik for my test lab as a reverse proxy, How can I specify the baseUrl in the configuration, I did not find a way in the Docs

Second there is an error in the generated client when I enable minio

public uploadFiles = async (config: UploadConfig): Promise<Response<UploadResponse[]>> => {
		try {
			// pass only files
			for (const pair of config.formData.entries()) {
				if (!(pair[1] instanceof Blob)) {
					config.formData.delete(pair[0]);
				}
			}
			const params = this.queryString({
				wg_api_hash: this.applicationHash,
			});
			if (this.csrfToken === undefined) {
				const res = await fetch(this.baseURL + "/" + this.applicationPath + "/auth/cookie/csrf", {
					credentials: "include",
					mode: "cors",
				});
				this.csrfToken = await res.text();
			}
			const headers: Headers = {
				...this.extraHeaders,
				Accept: "application/json",
				"WG-SDK-Version": this.sdkVersion,
			};
			if (this.csrfToken) {
				headers["X-CSRF-Token"] = this.csrfToken;
			}
			const body = config.formData;
			const f = fetchConfig.method === "POST" ? fetch : this.fetch; // only use SingleFlight for Queries
			const data = await f(this.baseURL + "/" + this.applicationPath + "/s3/" + config.provider + "/upload" + params, {
				headers,
				body,
				method: "POST",
				signal: config.abortSignal,
				credentials: "include",
				mode: "cors",
			});
			return {
				status: "ok",
				body: data,
			};
		} catch (e: any) {
			return {
				status: "error",
				message: e,
			};
		}
	};
```

const f = fetchConfig.method === "POST" ? fetch : this.fetch; // only use SingleFlight for Queries

fetchConfig is not defined as it is not passed in uploadFiles args

Thank your 
@jensneuse
Copy link
Member

Hey, thanks for bringing this up.
We're looking into fixing the generated code!

Regarding the baseURL, it can be configured this way on the client:

export const WunderGraphProvider: FunctionComponent<Props> = ({ endpoint, children }) => {

On the server, the baseURL can be configured via:
wunderctl up --listen_addr or wunderctl start --listen_addr

@Twathik
Copy link
Author

Twathik commented Feb 14, 2022

Thank you for the replay.

@Twathik
Copy link
Author

Twathik commented Feb 19, 2022

new ts error in the generated client in version 0.75 of the sdk

	public uploadFiles = async (config: UploadConfig): Promise<Response<UploadResponse[]>> => {
		try {
			// pass only files
			for (const pair of config.formData.entries()) {
				if (!(pair[1] instanceof Blob)) {
					config.formData.delete(pair[0]);
				}
			}
...
(method) FormData.entries(): IterableIterator<[string, FormDataEntryValue]>
Returns an array of key, value pairs for every entry in the list.

Type 'IterableIterator<[string, FormDataEntryValue]>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.ts(2569)

In addition of the Cannot find name 'fetchConfig'.in

...
	const body = config.formData;
			const f = fetchConfig.method === "POST" ? fetch : this.fetch; // only use SingleFlight for Queries
			const data = await f(this.baseURL + "/" + this.applicationPath + "/s3/" + config.provider + "/upload" + params, {
				headers,
				body,
				method: "POST",
				signal: config.abortSignal,
				credentials: "include",
				mode: "cors",
			});
....
```

As it is a generated code it is not possible to fix this without fixing the code generator


looking forward for this fix

Think you

@Twathik
Copy link
Author

Twathik commented Feb 23, 2022

Problem fixed in version 0.76 of the sdk thanks

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

3 participants