Closed tkamenoko closed 3 years ago
Describe the bug Sending query by GET fails when endpoint starts with / .
GET
/
To Reproduce
import { AwesomeGraphQLClient } from 'awesome-graphql-client' const client = new AwesomeGraphQLClient({ endpoint: '/graphql' }) await client.request(SomeQuery, variables, {method: "GET"})
This code shows an error: TypeError: Failed to construct 'URL': Invalid URL
TypeError: Failed to construct 'URL': Invalid URL
Expected behavior The client should accept a relative path as an endpoint.
Additional context It looks caused by this function: https://github.com/lynxtaa/awesome-graphql-client/blob/32ffb82814d928825b52c074ae6f6cdc52a334e2/src/util/formatGetRequestUrl.ts#L5-L15
URL constructor requires an absolute url or a relative path with a base url. See https://developer.mozilla.org/en-US/docs/Web/API/URL/URL
URL
Nice catch! I'll fix it today
Published awesome-graphq-client@0.9.1
Describe the bug Sending query by
GET
fails when endpoint starts with/
.To Reproduce
This code shows an error:
TypeError: Failed to construct 'URL': Invalid URL
Expected behavior The client should accept a relative path as an endpoint.
Additional context It looks caused by this function: https://github.com/lynxtaa/awesome-graphql-client/blob/32ffb82814d928825b52c074ae6f6cdc52a334e2/src/util/formatGetRequestUrl.ts#L5-L15
URL
constructor requires an absolute url or a relative path with a base url. See https://developer.mozilla.org/en-US/docs/Web/API/URL/URL