GithubHelp home page GithubHelp logo

lynxtaa / awesome-graphql-client Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 5.0 2.83 MB

GraphQL Client with file upload support for NodeJS and browser

Home Page: https://npm.im/awesome-graphql-client

License: MIT License

TypeScript 98.27% JavaScript 1.73%

awesome-graphql-client's People

Contributors

codebdy avatar dependabot[bot] avatar k9ordon avatar lynxtaa avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

awesome-graphql-client's Issues

Support sending `operationName`

OperationName is useful for logging purposes, frameworks like HotChocolate have a built-in field to handle it

image

Describe the solution you'd like
Pass operationName in the request payload

Describe alternatives you've considered
using a customFetch operation and extracting the operationName from the queries sent in

Additional context
Add any other context or screenshots about the feature request here.

Subscriptions support

Is your feature request related to a problem? Please describe.
Is it planned to add subscriptions support?

Describe the solution you'd like
Would like to use graphql subscriptions

Describe alternatives you've considered
N/A

Additional context
N/A

Next.js example

Hello, would be cool to have a Next.js example in README showing how to combine clientside and server side fetching

add the ability to change fetchOptions (or only headers) per request

Is your feature request related to a problem? Please describe.
Would be nice if you can setFetchOptions() (or only headers) per request.

Describe the solution you'd like
Setting some default headers in initial setup

const graphQlClient = new AwesomeGraphQLClient({
    endpoint: GRAPHQL_ENDPOINT,
    fetchOptions: {
          headers: {
            ...some default headers
        }
    }
});

// request with default headers/fetchOptions
graphQlClient.request(document, variables)

if some requests need an additional header

graphQlClient
    .setFetchOptions({
          headers: {
            ...additional headers
        }
    })
    .request(document, variables)

or only headers

graphQlClient
    .setHeaders({
        ...additional headers
    })
    .request(document, variables)

Describe alternatives you've considered
N/A

Additional context
N/A

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

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:

export function formatGetRequestUrl({
endpoint,
query,
variables,
}: {
endpoint: string
query: string
variables?: Record<string, unknown>
}): string {
const url = new URL(endpoint)

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

Typescript typings for package

Is your feature request related to a problem? Please describe.
When using this package in a typescript project I receive following error:

/path-to-project/node_modules/awesome-graphql-client/dist/index.modern.mjs' implicitly has an 'any' type.
  There are types at '/path-to-project/node_modules/awesome-graphql-client/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'awesome-graphql-client' library may need to update its package.json or typings.

NOTE: This problem is produced by vscode.

Describe the solution you'd like
I prefer to have a complete typing when using project or there should be a package like @types/awesome-graphql-client to add necessary typings.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

add option to change endpoint

Is your feature request related to a problem? Please describe.
Would be helpful if we can set the endpoint like the fetchOptions.

Describe the solution you'd like
add the possibility to set the endpoint like this client.setEndpoint(string).

Describe alternatives you've considered
NA

Additional context
NA

Support for persisted queries?

Is your feature request related to a problem? Please describe.
It would be great if this library support persisted queries, which means the server already knows the query the client is sending, and the client merely passes an "id" in the query string (GET) or "id" in the body (POST) rather than a query in the body

Describe the solution you'd like
A way for graphClient.request to pass an id corresponding to a query, or an alternative graphClient.requestId() where the first arg is an ID rather than the query itself

Describe alternatives you've considered
Alternatively, the library could provide a way to customize how operations are serialized, instead of just a hard-coded JSON.stringify(...)

Header Customization

Is your feature request related to a problem? Please describe.
It is common to have some authenticated urls which requires a token in header to give you access to the desired resource.
Unfortunately I didn't see any way to set my preferred header variable for authorization.

Describe the solution you'd like
Provide a method to give user ability to set necessary headers. For example:

client.setHeader({
     variable: value
})

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.