Ghirro / graphql-network

Chrome Devtool that provides a "network"-style tab for GraphQL requests to allow developers to debug more easily.
321 stars 33 forks source link

Support form data? #4

Closed rmosolgo closed 7 years ago

rmosolgo commented 8 years ago

Hi there! I was just trying out this extension but I found that my queries don't show up.

I see there are two ways for it to find queries: POST with a query in the JSON body; or Content-Type=application/graphql. I'm not sure if it's possible, but I'd like my queries to show up, but they work differently.

I'm using jQuery to send AJAX requests, basically like this:

$.post(
  graphqlURL, 
  {
    query: queryString, 
    variables: JSON.stringify(queryVariables)
  },
  responseHandlerFunction
)

By default, jQuery turns the parameters into Form Data, so my network tab looks like this:

image

(The Content-Type is application/json; charset=utf-8)

Is it possible to support this in the extension? Thanks for considering it!

Ghirro commented 8 years ago

Hi there,

I'll mark this for the next release version as it's a good point. I'm sure there's got to be a better way of discerning whether or not a query is GraphQL and I'll give it a go. I won't be able to get round ti it for a couple of weeks but in the meantime:

https://github.com/Ghirro/graphql-network/blob/master/src/lib/utils.js#L75

That's where the code that determines whether the query is valid as GraphQL (isGraphQL) and then parseEntry does the initial retrieval of the query. If you want to fork and patch yourself feel free.

Ghirro commented 7 years ago

Should now be supported

rmosolgo commented 7 years ago

Thanks, I look forward to giving it a try!!