哪些中继对象必须实现`Node`?

时间:2016-01-22 13:56:49

标签: relayjs

https://facebook.github.io/relay/graphql/objectidentification.htm非常明确#include <gst/gst.h> /* Structure to contain all our information, so we can pass it to callbacks */ typedef struct _CustomData { GstElement *pipeline; GstElement *source; GstElement *convert; GstElement *sink; GstElement *encode; } CustomData; int main(int argc, char *argv[]) { CustomData data; GstBus *bus; GstMessage *msg; GstStateChangeReturn ret; gboolean terminate = FALSE; /* Initialize GStreamer */ gst_init (&argc, &argv); /* Create the elements */ data.source = gst_element_factory_make ("videotestsrc", "source"); data.convert = gst_element_factory_make ("ffmpegcolorspace", "convert"); data.encode = gst_element_factory_make ("ffenc_pgm", "encode"); data.sink = gst_element_factory_make ("multifilesink", "sink"); /* Create the empty pipeline */ data.pipeline = gst_pipeline_new ("test-pipeline"); if (!data.pipeline || !data.source || !data.convert || !data.sink) { g_printerr ("Not all elements could be created.\n"); return -1; } /* Build the pipeline. Note that we are NOT linking the source at this * point. We will do it later. */ gst_bin_add_many (GST_BIN (data.pipeline), data.source, data.convert , data.encode, data.sink, NULL); if (!gst_element_link_many (data.source, data.convert, data.encode, data.sink, NULL)) { g_printerr ("Elements could not be linked.\n"); gst_object_unref (data.pipeline); return -1; } /* Modify the source's properties */ g_object_set (data.source, "pattern", 0, NULL); g_object_set (data.source, "num-buffers", 9, NULL); g_object_set(data.sink, "location", "frame%05d.pgm", NULL); /* Start playing */ ret = gst_element_set_state (data.pipeline, GST_STATE_PLAYING); if (ret == GST_STATE_CHANGE_FAILURE) { g_printerr ("Unable to set the pipeline to the playing state.\n"); gst_object_unref (data.pipeline); return -1; } /* Wait until error or EOS */ bus = gst_element_get_bus (data.pipeline); msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); /* Parse message */ if (msg != NULL) { GError *err; gchar *debug_info; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_ERROR: gst_message_parse_error (msg, &err, &debug_info); g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); g_clear_error (&err); g_free (debug_info); break; case GST_MESSAGE_EOS: g_print ("End-Of-Stream reached.\n"); break; default: /* We should not reach here because we only asked for ERRORs and EOS */ g_printerr ("Unexpected message received.\n"); break; } gst_message_unref (msg); } /* Free resources */ gst_object_unref (bus); gst_element_set_state (data.pipeline, GST_STATE_NULL); gst_object_unref (data.pipeline); return 0; } 是什么以及它的行为方式,但它并没有指定哪些对象必须实现它,或者如果你的对象没有实现的后果是什么?实现它。有哪些功能不起作用?这些物体完全被忽略了吗?并非现有规范中的所有对象(例如Node)都实现了它,因此它显然不是普遍要求的,但pageInfo有点特殊情况。

1 个答案:

答案 0 :(得分:4)

另一种思考Node接口的方法是实现它的对象是 refetchable 。可反复性有效地意味着一个对象具有一个ID,我可以用它来识别对象并检索它;按照惯例,这些ID通常是不透明的,但是将包含类型信息和该类型中的标识符(例如,字符串的Base-64编码,如“Account:1234”)。

Relay将以两种方式利用可再融资性:

  • 在称为“差异化”的过程中,如果您已经拥有由ID QWNjb3VudDoxMjM0标识的对象的某些数据(例如,nameaddress字段),那么您导航到我们显示一些其他字段(locationcreatedAt)的视图,然后Relay可以创建一个“重新获取”节点但只请求丢失字段的最小查询。
  • 相关地,Relay将使用Node接口来填充缺少的数据(例如:通过某些导航组合,您可能拥有视图中某些项目的完整信息,但需要为范围内的某些项填写location,或者您可以通过变异修改连接中的项目)。因此,在基本分页中,Relay通常最终会进行first + after查询以扩展连接,但如果您在真实应用中检查其网络流量,您还会看到它会生成{{ 1}}查询连接中的项目。

所以是的,node没有实现pageInfo你是对的,这样做是没有意义的。