Giter Club home page Giter Club logo

fetchql's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar gucheen avatar jameekim avatar kamleshchandnani 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  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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fetchql's Issues

Issues with typescript declarations

I was looking for a simple graphql client library and chose this one, and tried to use it in my typescript project. But even before I was able to setup the client instance, several problems stopped me.

  • All the interfaces are hidden (not exported), so I couldn't use them to declare types of my variables
  • As far as I understood by looking into the source code, not all properties in the interceptor objects are required, but the interface FetchQLInterceptor requires them all
  • The return types of the methods in the intercepter objects seem very odd; return Promise.reject(error) in the requestError does not work, even though the README has it as an example
  • There are some typos, like reueqstError in the interceptor or rejedct in the returned object of FetchQL instance methods (and now I realize they should return promises, I guess?)

If someone else can handle this then it is fine, but maybe I can fix some of the issues if that is needed. But I'm not sure if I will understand all underlying things going on in the source code. I also suggest adding typescript as a dev dependency and then testing if the type declarations enable users to successfully compile. Should I start working on this tomorrow? (It's late at night here so I need to go to bed)

Distribute unminified/ unbundled code

There is no reason to distribute a minified code. Furthermore, there is no reason to distribute a bundled code. All you are doing is preventing common chunk optimisation that could be achieved at the bundler level and increasing the overall script size.

Question on intercepting GraphQL response

Hello, I have a question I cannot find an answer for and wonder if you can help or if this library can accommodate.

The server I am sending a request to returns a response that is not a JSON object - or graphQL map.

It is actually just returns a 200/ok with a string of comma-separated values like this...

0,4,Received and queued,0,,,0,,,

Each of the values in this string represent a key or name that I need to map so the client receives a readable response. The length of the string and number of values will remain constant.

For example, in this string....

value 1 (0) = 'hostResponseCode'
value 2 (4) = 'hostDetailCode'
value 3 (Received and queued) = 'hostMessage'
value 4 (0) = 'statusCode'
value 5 () = 'statusMessage'
value 6 () = 'etc'
...

I just read in the GraphQL specs in 7.2 Response Format that:

A response to a GraphQL operation must be a map.
Am I out of luck or is there a way I can intercept this response before it is received, assign it to a json object and map these fields? Is your library only for after the response is received?

Thank you for any feedback - this one has me perplexed as I would really like to graphQL my backend....

What is `operationName` used for?

I am getting an error like GraphQLError: Unknown operation named "..."

I've noticed the object passed to the GraphQL server consists of:

{
    operationName: "...",
    query: "...",
    variables: { ... }
}

why operationName is passed when it should only send query and variables?

Successful responses with null data are rejected as errors

My API includes mutations that don't return any data. They're effectively requests for a low-priority async operation, and they return almost immediately with no information, by just returning null.

That's works fine and its perfectly valid GraphQL as far as I'm aware, but this library rejects these responses, due to

fetchql/src/index.js

Lines 192 to 196 in 07d08be

// if all properties of data is 'null'
const allDataKeyEmpty = Object.keys(data).every(key => !data[key]);
if (allDataKeyEmpty) {
return reject(errors);
}

In that code, a successful response that has no errors but which returns a { myOperation: null } result will throw undefined.

I don't think this case should throw. Even if it does, it should probably throw something clearer than undefined.

Question on intercepting GraphQL response

Hello, I have a question I cannot find an answer for and wonder if you can help or if this library can accommodate.

The server I am sending a request to returns a response that is not a JSON object - or graphQL map.

It is actually just returns a 200/ok with a string of comma-separated values like this...

0,4,Received and queued,0,,,0,,,

Each of the values in this string represent a key or name that I need to map so the client receives a readable response. The length of the string and number of values will remain constant.

For example, in this string....

value 1 (0) = 'hostResponseCode'
value 2 (4) = 'hostDetailCode'
value 3 (Received and queued) = 'hostMessage'
value 4 (0) = 'statusCode'
value 5 () = 'statusMessage'
value 6 () = 'etc'
...

I just read in the GraphQL specs in 7.2 Response Format that:

A response to a GraphQL operation must be a map.
Am I out of luck or is there a way I can intercept this response before it is received, assign it to a json object and map these fields? Is your library only for after the response is received?

Thank you for any feedback - this one has me perplexed as I would really like to graphQL my backend....

Does this library handle this? Sample RPC

Hello, sorry for the second post but your library has me hopeful for an answer after a long, hard day doing Google searches.

What I am reading is this library can handle an HTTP RPC call like this....

My published endpoint = https:mywebserver.com/process

can receive and process this actual endpoint:

https://webserver.com/service/Process.py?clientId=123456789&deviceId=001&userId=12334455&locationId=34

Is this correct? If so, can you give an example of how this looks in an code? I have to convert about 10 of these.

Errors do not cause rejection, as documented

The docs say:

If any errors exist(from query response), will reject the promise.

The code for this is here:

fetchql/src/index.js

Lines 184 to 199 in 07d08be

.then(({ data, errors }) => (
new Promise((resolve, reject) => {
this.onEnd();
// if data in response is 'null'
if (!data) {
return reject(errors || [{}]);
}
// if all properties of data is 'null'
const allDataKeyEmpty = Object.keys(data).every(key => !data[key]);
if (allDataKeyEmpty) {
return reject(errors);
}
return resolve({ data, errors });
})
));

In reality, the promise is only rejected if no data is returned. If data is returned and errors exist, the promise will resolve successfully with the data, ignoring the errors.

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.