Skip to content
Snippets Groups Projects
  1. Dec 15, 2021
  2. Dec 14, 2021
  3. Nov 18, 2021
  4. Nov 14, 2021
  5. Oct 18, 2021
  6. Oct 15, 2021
  7. Sep 21, 2021
  8. Sep 13, 2021
  9. Nov 12, 2020
    • Toan Nguyen's avatar
      add raw query/mutation functions (#3) · 0806e5ec
      Toan Nguyen authored
      In the case we developers want to decode JSON response ourself. Moreover, the default `UnmarshalGraphQL` function isn't ideal with complicated nested interfaces
      0806e5ec
  10. Sep 24, 2020
  11. Sep 01, 2020
  12. Dec 31, 2018
    • Shuhei Kitagawa's avatar
      internal/jsonutil: Skip unexported fields. · d48a9a75
      Shuhei Kitagawa authored
      This change makes jsonutil.UnmarshalGraphQL not consider unexported
      fields when looking for a matching field. This is done because such
      fields cannot be unmarshaled into, and it's more consistent with
      behavior of package encoding/json.
      
      Document unmarshalValue precondition that v must be addressing and
      not obtained by the use of unexported fields. That would make it
      settable, which is a requirement for the needs of unmarshalValue.
      We arrange the internal jsonutil code so that unmarshalValue is
      never called on an unsettable reflect.Value.
      
      Fixes #36.
      d48a9a75
  13. Nov 14, 2018
  14. Sep 24, 2018
    • Dmitri Shuralyov's avatar
      Include response body in non-200 OK error text. · e4a3a37e
      Dmitri Shuralyov authored
      When a GraphQL server returns a non-200 OK status code, it may be
      very helpful to for caller to know what the response body was.
      So, when such an error occurs, fetch the response body and
      include it in the returned error text.
      
      Fixes #29.
      Updates #24.
      e4a3a37e
  15. Sep 08, 2018
    • Dmitri Shuralyov's avatar
      Handle empty variables map correctly. · 36589939
      Dmitri Shuralyov authored
      Previously, only the nil variables map was handled correctly
      by fully omitting the variables from the generated GraphQL query.
      This change makes it so that an empty variables map is handled
      equivalently, and adds test coverage for it.
      36589939
  16. May 14, 2018
    • Dmitri Shuralyov's avatar
      Unmarshal data field only if present. (#23) · 62c9ce09
      Dmitri Shuralyov authored
      The data field may not be present in the response from GraphQL server.
      This is valid according to GraphQL specification, section 7.2.1
      (https://facebook.github.io/graphql/October2016/#sec-Data):
      
      	If an error was encountered before execution begins, the data entry
      	should not be present in the result.
      
      If it's not present, it won't have a valid JSON value. As a result,
      jsonutil.UnmarshalGraphQL will return an "unexpected end of JSON input"
      error, and prevent errors from the GraphQL response from being returned.
      We don't want that, so only try to Unmarshal the data value if it's
      present in the response.
      
      Fixes #22.
      62c9ce09
  17. May 09, 2018
  18. Mar 02, 2018
  19. Feb 23, 2018
    • Dmitri Shuralyov's avatar
      Populate partial results on query with some failure. · 8d3d3107
      Dmitri Shuralyov authored
      Sometimes, a part of the GraphQL query can fail, while the rest is
      successful. The response will include correct data, and include errors
      describing the part of the query that failed. (If the entire query
      failed, the response data will simply be null.)
      
      Unmarshal the GraphQL data into supplied structure before returning due
      to non-zero GraphQL errors. This way, when there's a partial failure,
      it's still possible to access the successful portion of the query.
      8d3d3107
  20. Dec 01, 2017
    • Dmitri Shuralyov's avatar
      Implement missing edge cases in queryArguments. (#7) · d0549edd
      Dmitri Shuralyov authored
      Previously, queryArguments was partially implemented to handle the most
      common types I had run into, with a TODO to complete the rest.
      
      This change implements the support for the remaining argument types.
      Now, slices of T are mapped to "[T]!", and pointers to slices of T are
      mapped to "[T]", as per GraphQL specification.
      
      Add a comment pointing out that commas are omitted because they're
      insignificant, and we're looking to produce minified output (less bytes
      to send over the network).
      
      Fixes #6.
      d0549edd
  21. Nov 27, 2017
    • Dmitri Shuralyov's avatar
      ident: Support brands in MixedCaps naming convention. · 671b9336
      Dmitri Shuralyov authored
      Helps shurcooL/octiconssvg#1.
      671b9336
    • Dmitri Shuralyov's avatar
      Automatically determine scalar types. (#4) · f0a007e6
      Dmitri Shuralyov authored
      Previously, I didn't know of a good way to determine scalar types
      automatically, so the interim solution was to require the user to
      specify the scalar types explicitly.
      
      This has the downside that it makes it not possible to substitute
      GraphQL-specific types with equivalent other types when unmarshaling
      results of a query. E.g., one would have to always use
      githubql.DateTime and couldn't use the standard time.Time.
      
      I've now discovered a way to determine scalar types automatically: they
      are structs that implement json.Unmarshaler interface.
      
      This commit implements the change to automatic scalar type detection,
      and removes the no longer necessary explicit passing of scalars.
      f0a007e6
  22. Nov 03, 2017
  23. Sep 16, 2017
    • Dmitri Shuralyov's avatar
      ident: Add RSS initialism. · d1a3e018
      Dmitri Shuralyov authored
      "RSS" is a valid initialism and should be treated as such. Add it to
      a section that is separate from the common initialisms from golint,
      to make it easier to keep those in sync with golint.
      
      This will be used during generation of github.com/shurcooL/octiconssvg
      package via dmitri.shuralyov.com/kebabcase package.
      d1a3e018
  24. Aug 31, 2017
  25. Aug 29, 2017
    • Dmitri Shuralyov's avatar
      internal/jsonutil: Fix array inside inline fragment edge case. · 68e5b1b3
      Dmitri Shuralyov authored
      We might be unmarshaling a single JSON value into multiple GraphQL
      fragments or embedded structs. This is represented by the d.vs stacks
      of values where to unmarshal.
      
      So, we shouldn't return a fatal error when finding something other than
      a slice in one of the places. Instead, skip it. However, if not a single
      slice is found in any of the places, then do return an error.
      
      This is similar to how missing struct fields are handled for objects.
      
      Fixes shurcooL/githubql#18.
      Updates shurcooL/githubql#15.
      68e5b1b3
  26. Jul 25, 2017
  27. Jul 24, 2017
  28. Jul 23, 2017
    • Dmitri Shuralyov's avatar
      Clean up last remaining hacky file. · e6665b33
      Dmitri Shuralyov authored
      The code quality has improved to an acceptable level and we no longer
      import any hacky packages.
      e6665b33
    • Dmitri Shuralyov's avatar
      ident: Rewrite hacky caseconv package. · 17b8e2b0
      Dmitri Shuralyov authored
      Both its API and implementation details are significantly improved.
      17b8e2b0
    • Dmitri Shuralyov's avatar
      Port the remaining tests from githubql. · 5df213a3
      Dmitri Shuralyov authored
      Define some custom GraphQL types for testing purposes only.
      5df213a3
    • Dmitri Shuralyov's avatar
      Add ability to provide custom GraphQL scalars. · 83343a21
      Dmitri Shuralyov authored
      GraphQL schemas may have custom scalars, in addition to the base ones
      defined in GraphQL spec.
      
      Users of graphql may declare Go types that map to such custom GraphQL
      scalars. For example:
      
      	type (
      		// DateTime is an ISO-8601 encoded UTC date.
      		DateTime struct{ time.Time }
      
      		// GitTimestamp is an ISO-8601 encoded date.
      		// Unlike the DateTime type, GitTimestamp is not converted in UTC.
      		GitTimestamp struct{ time.Time }
      
      		// URI is an RFC 3986, RFC 3987, and RFC 6570 (level 4) compliant URI.
      		URI struct{ *url.URL }
      
      		// X509Certificate is a valid x509 certificate.
      		X509Certificate struct{ *x509.Certificate }
      	)
      
      We don't want to expand those struct types when building queries. So,
      there needs to be a way to specify which Go types are actually scalars.
      
      This commit creates a way to do that.
      
      This is an interim solution. In the future, the GraphQL client may need
      the entire GraphQL schema. Once that's the case, it'll be possible to
      know what types are scalars from the schema, so it may be unneded to
      specify the Go types that map to GraphQL scalars.
      83343a21
    • Dmitri Shuralyov's avatar
      README: Fix typo. · 60da1d1d
      Dmitri Shuralyov authored
      60da1d1d