How backend to subscribe something changed

Dgraph is good for frontend, it’s also easy for backend to use with dgo.
But how to do when frontend and backend both to do something?

For example:
Frontend will create a product, and the backend will create a microservice for this product to commuticate with other services.
If we use RESTful API, we have an api CreateProduct or Product with POST method, it’s easy to know which product is created, and what is it.
But when we use dgraph, we just have an api with Request param, we don’t know what object is it.

How can we do for that?

Hi @kaisawind
Please have a look at the introspection capabilities to get an idea of what type of queries and mutations are serviced by a particular graphql endpoint. This is similar to HAL browser that a spring data application ships and provides metadata of service capabilities.
For example, in Dgraph, if you fire the following query from a graphql client (like altair) you will see the list of supported operations and other information.

  {
  __schema {
  __typename
  mutationType{
    name
    kind
    fields{
      name
    }
  }
  }
  }

Dgraph creates add, update and delete mutation with for each Dgraph schema type. Similarly, to get the list of queries/gets supported, please use the following query.

 {
  __schema {
  __typename
  queryType{
    name
    kind
    fields{
      name
    }
  }
  }
  }

The title of your post talks about listening to change. I am not sure I understand the question correctly, but perhaps this blog on Graphql subscription published recently might help. It talks about how a front-end is notified by Dgraph when changes occur.

From a Dgraph perspective, the following query provides the schema. This can be fired from Ratel.

schema {
  type
  index
  reverse
  tokenizer
  list
  count
  upsert
  lang
}
1 Like

yes, it’s subscription. Subscription is released at v200.07.
Thank you.

1 Like