I built the frontend code but backend was not ready yet. I needed to use mocks to test it. After backend was completed I had to rewrite some parts.- a frustrated engineer😤
schema {
query: Query
}
type Query {
get(id: ID!): Product
}
type Product {
id: ID! @id
name: String! @column
}
query getProduct($id: ID!) {
product(id: $id) {
id
name
}
}
Example: GraphQL
import graphene
class Query(graphene.ObjectType):
name = graphene.String()
def resolve_get_product(root, info, id):
product = get_product_from_db(id)
return {
'id': product.id,
'name': product.name,
}
schema = graphene.Schema(query=Query)
Example: Graphene (Python GraphQL)