machinebox / graphql

Simple low-level GraphQL HTTP client for Go
https://blog.machinebox.io/a-graphql-client-library-for-go-5bffd0455878
Apache License 2.0
937 stars 218 forks source link

Send query and variables in json body #12

Closed flexzuu closed 6 years ago

flexzuu commented 6 years ago

I think the issues #7 and #11 are both related to the the client sending data and variables as FormDataContentType but most server implementations expect them as application json in body like

{
  "query":  `query here`,
  "variables": obj with variables here
}
matryer commented 6 years ago

OK so this is definitely worth changing then?

flexzuu commented 6 years ago

yeah i think we should be agnostic how the server accepts it and add default implementations for the most common ones.

kamushadenes commented 6 years ago

Having problems on interacting with https://github.com/graphql-go/graphql because of this.

matryer commented 6 years ago

What happens if you're submitting files? The body has to be a multipart, and can't be JSON?

phated commented 6 years ago

@matryer APIs like Graphcool have a separate API endpoint for submitting files (with multipart) - https://www.graph.cool/docs/reference/graphql-api/file-management-eer4wiang0

matryer commented 6 years ago

Please update and try again following https://github.com/machinebox/graphql/pull/15.

matryer commented 6 years ago

Pull master, there’s an official way to do that now too.

On 24 May 2018, at 19:49, Kamus Hadenes notifications@github.com wrote:

Quick hack on https://github.com/kamushadenes/graphql https://github.com/kamushadenes/graphql got me going by implementing RunJSON()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/machinebox/graphql/issues/12#issuecomment-391820736, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGNG4aBIjP25kfLrbcRKbvymi9GvLJuks5t1wDHgaJpZM4SvL_Y.

matryer commented 6 years ago

@flexzuu this is fixed - please confirm?

matryer commented 6 years ago

Closing assuming this is fixed.