lynxtaa / awesome-graphql-client

GraphQL Client with file upload support for NodeJS and browser
https://npm.im/awesome-graphql-client
MIT License
59 stars 7 forks source link

Sending query by `GET` fails when endpoint starts with `/` #72

Closed tkamenoko closed 3 years ago

tkamenoko commented 3 years ago

Describe the bug Sending query by GET fails when endpoint starts with / .

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

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

lynxtaa commented 3 years ago

Nice catch! I'll fix it today

lynxtaa commented 3 years ago

Published awesome-graphq-client@0.9.1