<NME> getQueryBuilderForNodeInterface.js
<BEF> ADDFILE
<MSG> Created a helper to build node() queries

Summary: Identifying queries (eg. `node(id:"…")`)  need to have some `identifyingArg` metadata. To cut down repetition, we've extracted this into a `RelayNodeInterface.buildQuery` helper.

Reviewed By: @yungsters

Differential Revision: D2513133

fb-gh-sync-id: 15461a0dd0340f900c51ff3527b41d7eea95b1f2

<DFF> @@ -0,0 +1,39 @@
+/**
+ * Copyright 2013-2015, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ * @providesModule getQueryBuilderForNodeInterface
+ */
+
+'use strict';
+
+var RelayQuery = require('RelayQuery');
+
+import type RelayNodeInterface from 'RelayNodeInterface';
+import type {RootCallValue} from 'RelayQuery';
+
+function getQueryBuilderForNodeInterface(
+  RelayNodeInterface: RelayNodeInterface
+) {
+  function buildQuery(
+    identifyingArgValue?: ?Array<RootCallValue> | ?RootCallValue,
+    children?: ?Array<RelayQuery.Node>,
+    metadata?: ?{[key: string]: mixed},
+    name?: ?string
+  ): RelayQuery.Root {
+    return RelayQuery.Root.build(
+      RelayNodeInterface.NODE,
+      identifyingArgValue,
+      children,
+      {...metadata, identifyingArgName: RelayNodeInterface.ID},
+      name
+    );
+  }
+  return buildQuery;
+}
+
+module.exports = getQueryBuilderForNodeInterface;

{'addition_count': 39, 'commit_subject': 'Created a helper to build node() queries', 'deletion_count': 0, 'file_extension': '.js', 'lang': 'js', 'license': 'mit', 'repo_name': 'facebook/relay'}