Replies: 6 comments 4 replies
-
CC @deekerno, @AlicanC and @lostman for thoughts first. Then I'll bring in the fuel-core team to see what they think |
Beta Was this translation helpful? Give feedback.
-
@AlicanC Feel free to copy the pseudo-code or make any changes to it, or paste your own 👌🏽 just riffing and throwing out ideas |
Beta Was this translation helpful? Give feedback.
-
I believe this https://spec.graphql.org/June2018/ is the actual GraphQL spec? So might paste a 2nd iteration of pseudo-code that's a bit more inline with that ☝🏽 I think the specific parts of the spec that related to us are:
|
Beta Was this translation helpful? Give feedback.
-
I've attached below the generated types for some dummy While the code was initially written for generating types from contract ABIs, it defines (or helps you define) basic GQL concepts like nodes, connections and such so it's usable anywhere. Everything should be up to spec besides ordering and filtering (which aren't specced and are up to us to define.) The main concept here is the Note: the schema below doesn't implement the whole spec yet, and filtering/ordering is WIP. type Block implements Node {
id: ID!
number: Int!
hash: String!
}
type BlockConnection {
totalCount: Int!
nodes: [Block!]!
edges: [BlockEdge!]!
pageInfo: PageInfo!
}
type BlockEdge {
node: Block!
cursor: String!
}
input BlockFilterInput {
and: [BlockFilterInput!]
or: [BlockFilterInput!]
not: [BlockFilterInput!]
number: IntFilterInput
hash: StringFilterInput
}
input BlockOrderInput {
number: OrderDirection
hash: OrderDirection
}
input IDFilterInput {
and: [IDFilterInput!]
or: [IDFilterInput!]
not: [IDFilterInput!]
eq: IDFilterInput
in: [IDFilterInput!]
}
input IntFilterInput {
and: [IntFilterInput!]
or: [IntFilterInput!]
not: [IntFilterInput!]
eq: IntFilterInput
in: [IntFilterInput!]
gt: IntFilterInput
gte: IntFilterInput
lt: IntFilterInput
lte: IntFilterInput
}
interface Node {
id: ID!
}
input NodeFilterInput {
and: [NodeFilterInput!]
or: [NodeFilterInput!]
not: [NodeFilterInput!]
id: IDFilterInput
}
input NodeOrderInput {
id: OrderDirection
}
enum OrderDirection {
asc
desc
}
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
type Query {
block(id: ID!): Block
blocks(filter: BlockFilterInput, order: BlockOrderInput, first: Int, after: String, last: Int, before: String): BlockConnection!
transaction(id: ID!): Transaction
transactions(filter: TransactionFilterInput, order: TransactionOrderInput, first: Int, after: String, last: Int, before: String): TransactionConnection!
}
input StringFilterInput {
and: [StringFilterInput!]
or: [StringFilterInput!]
not: [StringFilterInput!]
eq: StringFilterInput
in: [StringFilterInput!]
gt: StringFilterInput
gte: StringFilterInput
lt: StringFilterInput
lte: StringFilterInput
}
type Transaction implements Node {
id: ID!
index: Int!
hash: String!
}
type TransactionConnection {
totalCount: Int!
nodes: [Transaction!]!
edges: [TransactionEdge!]!
pageInfo: PageInfo!
}
type TransactionEdge {
node: Transaction!
cursor: String!
}
input TransactionFilterInput {
and: [TransactionFilterInput!]
or: [TransactionFilterInput!]
not: [TransactionFilterInput!]
index: IntFilterInput
hash: StringFilterInput
}
input TransactionOrderInput {
index: OrderDirection
hash: OrderDirection
}
schema {
query: Query
} |
Beta Was this translation helpful? Give feedback.
-
Update: After what @AlicanC mentioned earlier, I think we can break the execution part issue into 2 parts.
Example using pseudo-code " schema file"
type FooEntity @entity {
id: ID!
name: Charfield!
}
type AnotherEntity @entity {
id: ID!
foo: FooEntity!
name: Charfield!
}
" << WITH ALL THE METADATA FROM JC's WORK >> "
type Query {
singleFoo(id: ID, name: Charfield) FooEntity
allFoos() [FooEntity]!
singleFooInList(id: [ID!]!) FooEntity
" so on and so forth.... "
manyFooInList(id: [ID!]!) [FooEntity]!
singleAnotherEntity(id: ID, name: Charfield) AnotherEntity
allAnotherEntities() [AnotherEntity]!
" so on and so forth.."
} |
Beta Was this translation helpful? Give feedback.
-
re: pre-canned queries -- I think this is a good idea. Just so I understand correctly: the suggestion is just to auto-generate a set of queries for each type marked with
Since we would have a strict criteria for pre-canned queries, we should be able to create methods that essentially concatenate re: arbitrary queries -- I think we have fairly solid functionality here already; it just needs to be tightened up and tested within an inch of its life. I think it would be helpful to have the client team (or even grantees) share what their queries they've seen or will typically use. |
Beta Was this translation helpful? Give feedback.
-
Context
The Idea
web server <> GraphQL query <> SQL
integration because no 3rd party crate exists to do thisString
and converting it into a SQL queryString
, executing the query, and returning the resultsHTTP Request -> {parse} -> GraphQL Query Document -> {translate} -> SQL query tokens -> {execute} -> SQL Rows -> {translate} -> GraphQL Response -> {convert} -> HTTP Response
Node
andEdge
based representation of this document, then iteratively convert each Node/Edge into a set of SQL tokensConsiderations
query { block { hash height transaction { id } } }
you know that 'Transaction' is a m2m child FK of 'Block', so for this value you look into the m2m table for the id, then the actual typdef table for the field value(s)NodeKind::Virtual
Pseudo-Code
Beta Was this translation helpful? Give feedback.
All reactions