diff --git a/appendices/0003_RFC/schema.gql b/appendices/0003_RFC/schema.gql new file mode 100644 index 0000000000000000000000000000000000000000..39570f09cbc91e2d333bc62c0f73fa92e22866db --- /dev/null +++ b/appendices/0003_RFC/schema.gql @@ -0,0 +1,334 @@ +# GraphQL schema for GVA API + +################################# +# Query +################################# + +type Query { + node: Node + current: Block + block(number: Int!): Block + blocks( + paging: Paging! + ): [Block!]! + identities( + paging: Paging! + issuer: String + usernameID: String + blockstamp: BlockstampInput + written: Boolean + ): Identities + memberships( + paging: Paging! + issuer: String + written: Boolean + ): Memberships + certifications( + paging: Paging! + issuer: String + target: String + written: Boolean + ): Certifications + revocations( + paging: Paging! + issuer: String + written: Boolean + ): Revocations + transactions( + paging: Paging! + issuer: String + written: Boolean + ): Transactions + sources( + paging: Paging! + issuer: String + txOnly: Boolean! = false + udOnly: Boolean! = false + ): [CoinSource]! +} + +################################# +# Queries return types +################################# + +type Identities { + counters: Counters! + identities: [Identity!]! +} + +type Memberships { + counters: Counters! + identities: [Membership!]! +} + +type Revocations { + counters: Counters! + revocations: [Revocation!]! +} + +type Certifications { + counters: Counters! + certifications: [Certification!]! +} + +type Transactions { + counters: Counters! + transactions: [Transaction!]! +} + +type Counters { + # Nombre total d'éléments + elements: Int! + # Total number of pages + pages: Int! +} + +################################# +# Inputs +################################# + +input Paging { + pageNumber: Int! = 0 + pageSize: Int! = 50 + fromBlock: Int! = 0 + # If toBlock is null, current block number is used + toBlock: Int +} + +input BlockstampInput { + # Block number + number: Int! + # Block hash + hash: String! +} + +################################# +# Tools types +################################# + +type Blockstamp { + # Block number + number: Int! + # Block hash + hash: String! +} + +################################# +# NODE types +################################# + +type Summary { + software: String! + version: String! + forkWindowSize: Int! +} + +type Sandbox { + # Depending on the implementation, the notion of "sandbox size" does not necessarily exist + size: Int + free: Int! +} + +type Sandboxes { + identities: Sandbox! + memberships: Sandbox! + certifications: Sandbox! + revocations: Sandbox! + transactions: Sandbox! +} + +type Node { + summary: Summary + sandboxes: Sandboxes +} + +################################# +# WOT types +################################# + +enum MembershipType { + IN, + OUT +} + +type Membership { + version: Int! + type: String! + currency: String! + issuer: String! + blockstamp: Blockstamp! + membershipType: MembershipType! + idtyUsername: String! + idtyBlockstamp: Blockstamp! + signature: String! + written: Boolean! +} + +type Certification { + version: Int! + type: String! + currency: String! + issuer: String! + blockstamp: Blockstamp! + target: String! + idtyUsername: String! + idtyBlockstamp: Blockstamp! + idtySig: String! + signature: String! + written: Boolean! +} + +type Revocation { + version: Int! + type: String! + currency: String! + issuer: String! + idtyUsername: String! + idtyBlockstamp: Blockstamp! + idtySig: String! + signature: String! + written: Boolean! +} + +type Identity { + version: Int! + type: String! + currency: String! + issuer: String! + blockstamp: Blockstamp! + usernameID: String! + signature: String! + written: Boolean! + membership: Membership + # Received certifications + recvCerts: [Certification!]! + # Identity revocation document (=null when identity not revoked) + revocation: Revocation +} + +################################# +# Transactions types (tx is alias for transaction) +################################# + +union CoinSource = UtxoInput | UdInput + +# UTXO Input (UTXO = Unused Transaction Ouput) +type UtxoInput { + amount: Int! + base: Int! + # transaction hash + hash: Int! + # output index + index: Int! +} + +# Universal Dividend input +type UdInput { + amount: Int! + base: Int! + pubkey: Int! + blockNumer: Int! +} + +# Transaction unlock source +type TxUnlock { + # Input index + index: Int! + # List of proof to unlock funds + unlocks: String! +} + +# Transaction output +type TxOuput { + amout: Int! + base: Int! + conditions: String! +} + +type Transaction { + version: Int! + type: String! + currency: String! + issuers: [String!]! + blockstamp: Blockstamp! + locktime: Int! + inputs: [CoinSource!]! + unlocks: [TxUnlock!]! + outputs: [TxOuput!]! + comment: String! + signatures: [String!]! + hash: String! + written: Boolean! +} + +################################# +# Block type +################################# + +type CompactRevocation { + issuer: String! + signature: String! +} + +type CompactCertification { + issuer: String! + target: String! + blockNumber: Int! + signature: String! +} + +type Block { + version: Int! + type: String! + currency: String! + issuer: String! + number: Int! + powMin: Int! + time: String! + mediantime: String! + membersCount: Int! + monetaryMass: Int! + unitBase: Int! + issuersCount: Int! + issuersFrame: Int! + issuersFrameVar: Int! + parameters: String + previousHash: String + dividend: Int + identities: [Identity!]! + joiners: [Membership!]! + actives: [Membership!]! + leavers: [Membership!]! + revoked: [CompactRevocation!]! + excluded: [String!]! + certifications: [CompactCertification!]! + transactions: [Transaction!]! + innerHash: String! + nonce: String! + signature: String! + hash: String! + raw: String! +} + +################################# +# Mutations +################################# + +# All mutations returns null if at least one document is invalid or if there is not enough space in the sandbox +type Mutation { + addIdentities ( + rawDocuments: [String!]! + ): [Identity!] + addMemberships ( + rawDocuments: [String!]! + ): [Membership!] + addCertifications ( + rawDocuments: [String!]! + ): [Certification!] + addRevocations ( + rawDocuments: [String!]! + ): [Revocation!] + addTransactions ( + rawDocuments: [String!]! + ): [Transaction!] +} diff --git a/rfc/0003 RFC GraphQL API for Duniter Clients.md b/rfc/0003 RFC GraphQL API for Duniter Clients.md index dbd9344f5d414c78eda710a8ac85d310a8b0e3ab..2eb3c15d25c6921b5c0b757fef3473771459bd5e 100644 --- a/rfc/0003 RFC GraphQL API for Duniter Clients.md +++ b/rfc/0003 RFC GraphQL API for Duniter Clients.md @@ -374,78 +374,7 @@ So the websoket channel path is automatically deducted from the optionnal path: ## API GraphQL Schema -```graphql -schema { - query: Query - mutation: Mutation -} - -################################# -# NODE types -################################# - -type Node { - summary: Summary - sandboxes: Sandboxes -} - -type Summary { - software: String! - version: String! - forkWindowSize: Int! -} - -type Sandbox { - size: Int! - free: Int! -} - -type Sandboxes { - identities: Sandbox! - memberships: Sandbox! - transactions: Sandbox! -} - -################################# -# WOT types -################################# - -type Identity { - version: Int! - type: String! - currency: String! - issuer: String! - uniqueID: String! - timestamp: String! - signature: String! - written: Boolean! -} - -################################# -# NODE queries -################################# - -type Query { - node: Node - getIdentities( - issuer: String - uniqueID: String - timestamp: String - written: Boolean - ): [Identity!] -} - -################################# -# WOT mutations -################################# - -type Mutation { - addIdentity ( - signedRaw: String! - ): Identity -} - -``` +See [schema.gql](../appendices/0003_RFC/schema.gql) --- End of the document.