Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add graphql replication endpoints #100

Merged
merged 38 commits into from
Jun 11, 2022
Merged

Conversation

pietgeursen
Copy link
Collaborator

@pietgeursen pietgeursen commented May 4, 2022

Adds graphql endpoints useful for replication.

📋 Checklist

  • Add tests that cover your changes
  • Add this PR to the Unreleased section in CHANGELOG.md
  • Link this PR to any issues it closes
  • New files contain a SPDX license header

Closes #114 and #116 and #112


If at all possible I'm going to turn PR review comments requesting changes into issues that can be addressed later in small PRs. This PR is huge (Sorry!) and I'm scared of the time it will take to keep it mergable if it drags out.

So maybe let me know what things must be fixed before this PR is merged and what can be dealt with separately.

@sandreae
Copy link
Member

sandreae commented May 4, 2022

Hi @pietgeursen! I'm working on storage methods tomorrow and some of next week. So far I've been working on the db structure and simple inserts and gets, thinking more from the node internals rather than replication. I'd like to move onto this though 👍 is there somewhere I can see what you are wanting? Or if not, and you feel like writing me a wish-list, I can try to make it happen 😄

@pietgeursen pietgeursen changed the base branch from development to entry-store-updates May 10, 2022 08:54
@adzialocha adzialocha linked an issue May 10, 2022 that may be closed by this pull request
Base automatically changed from entry-store-updates to development May 17, 2022 12:30
@sandreae
Copy link
Member

I'm still working on the storage provider... got quite far with it and wondering if we want an AuthorStore. Currently we don't have a nice way to query for what authors exist, I don't think we ever needed it yet.... but if I build that into the storage provider, I wondered if you wanted anything in particular? I know you are gunna be using author aliases, but I'm not sure if this is something very temporary, or if you'd want it storing?

@pietgeursen
Copy link
Collaborator Author

pietgeursen commented May 18, 2022 via email

aquadoggo/src/context.rs Outdated Show resolved Hide resolved
aquadoggo/src/db/provider.rs Outdated Show resolved Hide resolved
aquadoggo/src/graphql/ping/mod.rs Outdated Show resolved Hide resolved
aquadoggo/src/graphql/replication/context.rs Outdated Show resolved Hide resolved
aquadoggo/README.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 3, 2022

Codecov Report

Merging #100 (c5123aa) into development (5c604ef) will decrease coverage by 5.61%.
The diff coverage is 50.69%.

@@               Coverage Diff               @@
##           development     #100      +/-   ##
===============================================
- Coverage        94.22%   88.60%   -5.62%     
===============================================
  Files               28       42      +14     
  Lines             1938     2202     +264     
===============================================
+ Hits              1826     1951     +125     
- Misses             112      251     +139     
Impacted Files Coverage Δ
aquadoggo/src/bin/dump_gql_schema.rs 0.00% <0.00%> (ø)
aquadoggo/src/db/provider.rs 87.50% <ø> (ø)
aquadoggo/src/db/stores/log.rs 97.97% <ø> (ø)
aquadoggo/src/graphql/api.rs 50.00% <0.00%> (ø)
aquadoggo/src/graphql/client/request.rs 70.58% <ø> (ø)
aquadoggo/src/graphql/client/response.rs 100.00% <ø> (ø)
...doggo/src/graphql/replication/entry_and_payload.rs 0.00% <0.00%> (ø)
...rc/graphql/replication/single_entry_and_payload.rs 0.00% <0.00%> (ø)
aquadoggo/src/graphql/replication/entry.rs 16.66% <16.66%> (ø)
aquadoggo/src/graphql/replication/entry_hash.rs 20.00% <20.00%> (ø)
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c604ef...c5123aa. Read the comment docs.

@cafca
Copy link
Member

cafca commented Jun 3, 2022

Reviewing this atm, please hold merging.

Copy link
Member

@cafca cafca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite exciting to see replication enter the picture! And how fitting that this pr has that nice round number. In my comments I mentioned when things can also be handled in a follow-up. The main thing for me here is that I would like to understand better the approach with generating the schema before hand or maybe at least understand whether this is fundamentally in conflict with the way i've started to implement dynamic queries #141.

If anybody wants to try

mutation put {
  publishEntry(
    entryEncoded: "00bedabb435758855968b3e2de2aa1f653adfbb392fcf9cb2295a68b2eca3cfb030101a200204b771d59d76e820cbae493682003e99b795e4e7c86a8d6b4c9ad836dc4c9bf1d3970fb39f21542099ba2fbfd6ec5076152f26c02445c621b43a7e2898d203048ec9f35d8c2a1547f2b83da8e06cadd8a60bb45d3b500451e63f7cccbcbd64d09",
  	operationEncoded: "a466616374696f6e6663726561746566736368656d61784a76656e75655f30303230633635353637616533376566656132393365333461396337643133663866326266323364626463336235633762396162343632393331313163343866633738626776657273696f6e01666669656c6473a1676d657373616765a26474797065637374726576616c7565764f68682c206d79206669727374206d65737361676521"
  ) {
    logId,
    seqNum,
    backlink,
    backlink,
    skiplink
  }
}
query retrieve {
  entryByLogIdAndSequence(
    logId: 1, 
    sequenceNumber: 1, 
    author: { 
      publicKey: "bedabb435758855968b3e2de2aa1f653adfbb392fcf9cb2295a68b2eca3cfb03" 
    } 
  ) {
    entry,
    payload
  }
}

Comment on lines 19 to 21
pub mod db;
mod errors;
mod graphql;
pub mod graphql;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only make these pub if we want library consumers to use these directly. As they are only pub for the dump_gql_schema bin I would suggest to instead just export a utility function that returns the schema as String, which is called from the bin, instead of these complete modules.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it pub assuming it's going to be useful if / when I get to using qp2p.

aquadoggo/README.md Outdated Show resolved Hide resolved
aquadoggo/src/graphql/replication/mod.rs Outdated Show resolved Hide resolved
aquadoggo/src/graphql/replication/mod.rs Outdated Show resolved Hide resolved
aquadoggo/src/graphql/replication/author.rs Outdated Show resolved Hide resolved

/// The public key of an entry
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PublicKey(pub Author);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you are calling this PublicKey and not Author :D

Thinking a bit about the naming in general, you chose to use "payload" instead of "operation" and use both "author", which bamboo uses, and "public key", which p2panda prefers. We chose to go with "public key" in order to distinguish the data type public key from human authors - who can have multiple public keys. Also see the second bullet point in the "Authors" section here.

I think it might improve clarity to use the same naming as in the rest of p2panda (operation instead of payload and consistently "public key"), also because with the addition of schemas this replication system will not be agnostic of the payload content (otherwise this could also just use bamboo's naming).

Maybe I am being too nitpicky though - @sandreae @adzialocha do you have an opinion?

(can be a follow-up)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong feeling on this right now, we still need to do some renaming in p2panda-rs so maybe we could review this again later?

CHANGELOG.md Show resolved Hide resolved
aquadoggo/src/graphql/context.rs Show resolved Hide resolved
@pietgeursen pietgeursen requested review from cafca and adzialocha and removed request for adzialocha June 7, 2022 08:57
Copy link
Member

@adzialocha adzialocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy doesn't seem to be happy, maybe that needs fixing before merging, otherwise it's good to go! ✌️✨🌟

@sandreae
Copy link
Member

sandreae commented Jun 10, 2022

A few of those clippy errors are coming from db/store as some modules there were made public (so now need doc strings). I'm happy to fix those in a follow-up PR.

@pietgeursen
Copy link
Collaborator Author

I've tidied up all the clippy warnings. I had to add a few doc strings in @cafca's graphql client stuff, make sure you're ok with them.

@pietgeursen pietgeursen merged commit bf6ccb1 into development Jun 11, 2022
@pietgeursen pietgeursen deleted the add-gql-replication-types branch June 11, 2022 08:43
@pietgeursen
Copy link
Collaborator Author

😌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants