Skip to content

Commit

Permalink
Update links to graphql client repository (#112)
Browse files Browse the repository at this point in the history
* Update README.md

* docs: Update README.md and client.rb to reflect correct repository links of graphql-client

* docs: Fix typo in CONTRIBUTING.md regarding ignored issues

* Update CHANGELOG
  • Loading branch information
th1988 authored Nov 10, 2024
1 parent 849739c commit c9f6f1a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### (Next)
* Your contribution here.
* [#113](https://github.com/ashkan18/graphlient/pull/113): Fix CI builds - [@yuki24](https://github.com/yuki24).
* [#112](https://github.com/ashkan18/graphlient/pull/112): Update graphql-client github repository links in README - [@th1988](https://github.com/th1988).

### 0.8.0 (2024/01/06)
* [#110](https://github.com/ashkan18/graphlient/pull/110): Ensure correct Faraday JSON response body parsing with invalid response header - [@taylorthurlow](https://github.com/taylorthurlow).
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ We definitely appreciate pull requests that highlight or reproduce a problem, ev

Implement your feature or bug fix.

Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ignored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.

Make sure that `bundle exec rake` completes without errors.

Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ A friendlier Ruby client for consuming GraphQL-based APIs. Built on top of your
- [Create API Client Classes with Graphlient::Extension::Query](#create-api-client-classes-with-graphlientextensionquery)
- [Swapping the HTTP Stack](#swapping-the-http-stack)
- [Testing with Graphlient and RSpec](#testing-with-graphlient-and-rspec)
- [License](#license)
- [License](#license)

## Installation

Expand All @@ -46,7 +46,7 @@ client = Graphlient::Client.new('https://test-graphql.biz/graphql',
```

| http_options | default | type |
|---------------|---------|---------|
| ------------- | ------- | ------- |
| read_timeout | nil | seconds |
| write_timeout | nil | seconds |

Expand Down Expand Up @@ -216,7 +216,9 @@ client.query(ids: [42]) do
end
end
```

Graphlient supports following Scalar types for parameterized queries by default:

- `:id` maps to `ID`
- `:boolean` maps to `Boolean`
- `:float` maps to `Float`
Expand Down Expand Up @@ -244,7 +246,6 @@ end

You can `parse` and `execute` queries separately with optional variables. This is highly recommended as parsing a query and validating a query on every request adds performance overhead. Parsing queries early allows validation errors to be discovered before request time and avoids many potential security issues.


```ruby
# parse a query, returns a GraphQL::Client::OperationDefinition
query = client.parse do
Expand Down Expand Up @@ -279,7 +280,7 @@ client.execute query, ids: [42]

### Dynamic vs. Static Queries

Graphlient uses [graphql-client](https://github.com/github/graphql-client), which [recommends](https://github.com/github/graphql-client/blob/master/guides/dynamic-query-error.md) building queries as static module members along with dynamic variables during execution. This can be accomplished with graphlient the same way.
Graphlient uses [graphql-client](https://github.com/github-community-projects/graphql-client), which [recommends](https://github.com/github-community-projects/graphql-client/blob/master/guides/dynamic-query-error.md) building queries as static module members along with dynamic variables during execution. This can be accomplished with graphlient the same way.

Create a new instance of `Graphlient::Client` with a URL and optional headers.

Expand Down Expand Up @@ -321,7 +322,7 @@ Execute the query.
response = SWAPI::Client.execute(SWAPI::InvoiceQuery, id: 42)
```

Note that in the example above the client is created with `allow_dynamic_queries: false` (only allow static queries), while graphlient defaults to `allow_dynamic_queries: true` (allow dynamic queries). This option is marked deprecated, but we're proposing to remove it and default it to `true` in [graphql-client#128](https://github.com/github/graphql-client/issues/128).
Note that in the example above the client is created with `allow_dynamic_queries: false` (only allow static queries), while graphlient defaults to `allow_dynamic_queries: true` (allow dynamic queries). This option is marked deprecated, but we're proposing to remove it and default it to `true` in [graphql-client#128](https://github.com/github-community-projects/graphql-client/issues/128).

### Generate Queries with Graphlient::Query

Expand All @@ -342,7 +343,7 @@ query.to_s

### Use of Fragments

[Fragments](https://github.com/github/graphql-client#defining-queries) should be referred by constant:
[Fragments](https://github.com/github-community-projects/graphql-client#defining-queries) should be referred by constant:

```ruby
module Fragments
Expand Down Expand Up @@ -373,7 +374,7 @@ end
```

The wrapped response only allows access to fields that have been explicitly asked for.
In this example, while `id` has been referenced directly in the main query, `feeInCents` has been spread via fragment and trying to access it in the original wrapped response will throw [`GraphQL::Client::ImplicitlyFetchedFieldError`](https://github.com/github/graphql-client/blob/master/guides/implicitly-fetched-field-error.md) (to prevent data leaks between components).
In this example, while `id` has been referenced directly in the main query, `feeInCents` has been spread via fragment and trying to access it in the original wrapped response will throw [`GraphQL::Client::ImplicitlyFetchedFieldError`](https://github.com/github-community-projects/graphql-client/blob/master/guides/implicitly-fetched-field-error.md) (to prevent data leaks between components).

```ruby
response = client.execute(invoice_query)
Expand Down
2 changes: 1 addition & 1 deletion lib/graphlient/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def execute(query, variables = nil)
query = client.parse(query) if query.is_a?(String)
rc = client.query(query, **query_params)
raise Graphlient::Errors::GraphQLError, rc if rc.errors.any?
# see https://github.com/github/graphql-client/pull/132
# see https://github.com/github-community-projects/graphql-client/pull/132
# see https://github.com/exAspArk/graphql-errors/issues/2
raise Graphlient::Errors::ExecutionError, rc if errors_in_result?(rc)
rc
Expand Down

0 comments on commit c9f6f1a

Please sign in to comment.