Skip to content

Commit

Permalink
chore: tidy some things (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocorradini committed Jun 29, 2024
1 parent a167a2a commit 1233eb5
Show file tree
Hide file tree
Showing 25 changed files with 156 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
app-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down
57 changes: 22 additions & 35 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,44 @@ env:
jobs:
check-format:
# Skip draft release PRs
if: ${{ github.actor_id != '166155226' || github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
if: github.actor_id != '166155226' || github.event_name != 'pull_request' || github.event.pull_request.draft == false

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/[email protected]
with:
components: rustfmt
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Check format
run: cargo fmt --all --check

build:
# Skip draft release PRs
if: ${{ github.actor_id != '166155226' || github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
if: github.actor_id != '166155226' || github.event_name != 'pull_request' || github.event.pull_request.draft == false

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/[email protected]
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Build
shell: bash
run: |
cargo build --all-features
run: cargo build --workspace --all-features
- name: Build tests
shell: bash
run: |
cargo test --all-features --no-run
run: cargo test --workspace --all-features --no-run
- name: Run tests
shell: bash
run: |
cargo test --all-features
run: cargo test --workspace --all-features
- name: Build examples
shell: bash
run: |
cargo build --all --examples
- name: Build example tests
shell: bash
run: |
cargo test --all --examples --no-run
cargo test --all --examples
- name: Run example tests
shell: bash
run: |
cargo test --all --examples
run: cargo build --workspace --all-features --examples
- name: Build examples tests
run: cargo test --workspace --all-features --examples --no-run
- name: Run examples tests
run: cargo test --workspace --all-features --examples
- name: Run clippy
run: cargo clippy --all --all-features
25 changes: 24 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
/target
# Generated by Cargo will have compiled files and executables
/debug/
/target/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Log
*.log

# JetBrains
/.idea/

# Visual Studio Code
/.vscode/

# Local History for Visual Studio Code
/.history/

# Converage
/coverage/
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ all APIs might be changed.

### Breaking Changes

- All Connection trait functions now return impl Future instead of BoxFuture
- All Connection trait functions now return impl Future instead of BoxFuture
([#108](https://github.com/obmarg/graphql-ws-client/pull/108))
- Removed the legacy API that was deprecated in v0.8.0
- Removed the legacy API that was deprecated in v0.8.0
([#81](https://github.com/obmarg/graphql-ws-client/pull/81))
- The deprecated `async-tungstenite` feature has been removed. Use the
`tungstenite` feature instead, which works with `async-tungtenite`,
Expand Down
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ There's a few different ways to contribute:
please [create an issue][NewIssue] to discuss or send a message [on
discord][Discord].
- If you'd like to contribute to an existing issue feel free to comment on the
issue and let us know. If anything isn't clear someone will be happy to
issue and let us know. If anything isn't clear someone will be happy to
explain (the project is still fairly new, and I have treated the issue
tracker like a notepad occasionally, sorry about that 😬).
- If you'd like to contribute but you're not sure how:
Expand Down Expand Up @@ -49,9 +49,10 @@ You can do this by:
understand the context around & reason for the changes.
5. A maintainer will review the PR as soon as possible, and once it is approved
will merge and make a release.

[COC]: ./CODE_OF_CONDUCT.md
[Discord]: https://discord.gg/Y5xDmDP
[Discussions]: https://github.com/obmarg/graphql-ws-client/discussions/new
[GFI]: https://github.com/obmarg/graphql-ws-client/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22
[Milestones]: https://github.com/obmarg/graphql-ws-client/milestones
[NewIssue]: https://github.com/obmarg/graphql-ws-client/issues/new/choose
23 changes: 22 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ edition = "2021"
resolver = "2"
description = "A graphql over websockets client"
keywords = ["graphql", "client", "api", "websockets", "subscriptions"]
categories = [
"asynchronous",
"network-programming",
"wasm",
"web-programming",
"web-programming::websocket",
]
license = "Apache-2.0"
autoexamples = false
documentation = "https://docs.rs/graphql-ws-client"
Expand Down Expand Up @@ -58,8 +65,22 @@ tokio-stream = { version = "0.1", features = ["sync"] }

graphql-ws-client.path = "."

graphql-ws-client.features = ["client-cynic", "client-graphql-client", "tungstenite"]
graphql-ws-client.features = [
"client-cynic",
"client-graphql-client",
"tungstenite",
]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace.lints.rust]
unsafe_code = "forbid"

[workspace.lints.clippy]
cargo = { level = "warn", priority = -1 }
multiple_crate_versions = "allow"

[lints]
workspace = true
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<h1>Graphql Websocket Client</h1>
<h1>GraphQL Websocket Client</h1>

<p>
<strong>Runtime agnostic graphql websocket client</strong>
Expand All @@ -12,9 +12,9 @@
</p>

<h4>
<a href="https://github.com/obmarg/graphql-ws-client/tree/master/examples/examples">Examples</a>
<a href="https://github.com/obmarg/graphql-ws-client/tree/main/examples/examples">Examples</a>
<span> | </span>
<a href="https://github.com/obmarg/graphql-ws-client/blob/master/CHANGELOG.md">Changelog</a>
<a href="https://github.com/obmarg/graphql-ws-client/blob/main/CHANGELOG.md">Changelog</a>
</h4>
</div>

Expand All @@ -41,8 +41,8 @@ The library offers integrations with some popular GraphQL clients with feature f

The documentation is quite limited at the moment, here are some sources:

1. The provided [examples](https://github.com/obmarg/graphql-ws-client/tree/master/examples/examples)
2. The reference documentation on [docs.rs](https://docs.rs/graphql-ws-client/)
1. The provided [examples](https://github.com/obmarg/graphql-ws-client/tree/main/examples/examples)
2. The reference documentation on [docs.rs](https://docs.rs/graphql-ws-client)

## Logging

Expand Down
5 changes: 4 additions & 1 deletion examples-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
[dependencies]
async-std = { version = "1.9", features = ["attributes"] }
cynic = { version = "3" }
futures = { version = "0.3"}
futures = { version = "0.3" }
log = "0.4"

# wasm-specific
Expand All @@ -27,3 +27,6 @@ features = ["cynic", "ws_stream_wasm"]

[dev-dependencies]
insta = "1.11"

[lints]
workspace = true
11 changes: 8 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ publish = false

[dependencies]
async-std = { version = "1.9", features = ["attributes"] }
async-tungstenite = { version = "0.26", features = ["async-std-runtime", "tokio-runtime"] }
async-tungstenite = { version = "0.26", features = [
"async-std-runtime",
"tokio-runtime",
] }
cynic = { version = "3" }
futures = { version = "0.3"}
futures = { version = "0.3" }
graphql_client = { version = "0.14" }
serde = "1"
tokio = { version = "1.15", features = ["rt-multi-thread", "macros"] }
Expand All @@ -22,6 +25,8 @@ version = "0.10.1"
default-features = false
features = ["cynic", "tungstenite"]


[dev-dependencies]
insta = "1.11"

[lints]
workspace = true
4 changes: 2 additions & 2 deletions examples/examples/cynic-mulitiple-subscriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ async fn main() {
futures::join!(
async move {
while let Some(item) = first_subscription.next().await {
println!("{:?}", item);
println!("{item:?}");
}
},
async move {
while let Some(item) = second_subscription.next().await {
println!("{:?}", item);
println!("{item:?}");
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/cynic-single-subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async fn main() {
.unwrap();

while let Some(item) = subscription.next().await {
println!("{:?}", item);
println!("{item:?}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/examples/graphql-client-single-subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ async fn main() {
.unwrap();

while let Some(item) = subscription.next().await {
println!("{:?}", item);
println!("{item:?}");
}
}
2 changes: 1 addition & 1 deletion examples/examples/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async fn main() {
let mut stream = client.subscribe(build_query()).await.unwrap();
println!("Running subscription apparently?");
while let Some(item) = stream.next().await {
println!("{:?}", item);
println!("{item:?}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/doc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ impl crate::graphql::GraphqlOperation for Subscription {
}
}

pub fn spawn<T>(_future: impl Future<Output = T> + Send + 'static) {}
pub fn spawn<T>(_: impl Future<Output = T> + Send + 'static) {}
8 changes: 4 additions & 4 deletions src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub trait GraphqlOperation: serde::Serialize {

#[cfg(feature = "client-cynic")]
mod cynic {
use super::*;
use super::GraphqlOperation;

#[cfg_attr(docsrs, doc(cfg(feature = "client-cynic")))]
impl<ResponseData, Variables> GraphqlOperation
Expand All @@ -47,19 +47,19 @@ pub use self::graphql_client::StreamingOperation;

#[cfg(feature = "client-graphql-client")]
mod graphql_client {
use super::*;
use super::GraphqlOperation;
use ::graphql_client::{GraphQLQuery, QueryBody, Response};
use std::marker::PhantomData;

/// A streaming operation for a GraphQLQuery
/// A streaming operation for a [`GraphQLQuery`]
#[cfg_attr(docsrs, doc(cfg(feature = "client-graphql-client")))]
pub struct StreamingOperation<Q: GraphQLQuery> {
inner: QueryBody<Q::Variables>,
phantom: PhantomData<Q>,
}

impl<Q: GraphQLQuery> StreamingOperation<Q> {
/// Constructs a StreamingOperation
/// Constructs a [`StreamingOperation`]
pub fn new(variables: Q::Variables) -> Self {
Self {
inner: Q::build_query(variables),
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ mod next;

#[cfg(feature = "ws_stream_wasm")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws_stream_wasm")))]
/// Integration with the ws_stream_wasm library
/// Integration with the [ws_stream_wasm][1] library
///
/// [1]: https://docs.rs/ws_stream/latest/ws_stream
pub mod ws_stream_wasm;

#[cfg(feature = "tungstenite")]
Expand Down
Loading

0 comments on commit 1233eb5

Please sign in to comment.