Skip to content

Commit

Permalink
Rename outfileType 'apollo-js' to 'js' for the JS client
Browse files Browse the repository at this point in the history
The generated JS code accounts for 'relay', 'apollo', and plain JS. This
rename is to not make it seem like this only works for 'apollo'.

We can always add more specific generators in the future.
  • Loading branch information
kevinjalbert committed Nov 30, 2017
1 parent a74b913 commit 4328dda
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion javascript_client/cli.js
Expand Up @@ -15,7 +15,7 @@ required arguments:
optional arguments:
--path=<path> Path to .graphql files (default is "./**/*.graphql")
--outfile=<generated-filename> Target file for generated code
--outfile-type=<type> Target type for generated code (default is "apollo-js")
--outfile-type=<type> Target type for generated code (default is "js")
--key=<key> HMAC authentication key
--mode=<mode> Treat files like a certain kind of project:
relay: treat files like relay-compiler output
Expand Down
@@ -1,10 +1,10 @@
var { generateClient, APOLLO_JS_TYPE } = require("../generateClient")
var { generateClient, JS_TYPE } = require("../generateClient")
var fs = require("fs")

function withExampleClient(mapName, callback) {
// Generate some code and write it to a file
var exampleMap = { a: "b", "c-d": "e-f" }
var jsCode = generateClient("example-client", exampleMap, APOLLO_JS_TYPE)
var jsCode = generateClient("example-client", exampleMap, JS_TYPE)
var filename = "./" + mapName + ".js"
fs.writeFileSync(filename, jsCode)

Expand Down
10 changes: 5 additions & 5 deletions javascript_client/sync/generateClient.js
@@ -1,14 +1,14 @@
var sendPayload = require("./sendPayload")
var prepareRelay = require("./prepareRelay")

var generateApolloJS = require("./outfileGenerators/apolloJS")
var generateJs = require("./outfileGenerators/js")
var generateJson = require("./outfileGenerators/json")

var APOLLO_JS_TYPE = "apollo-js";
var JS_TYPE = "js";
var JSON_TYPE = "json";

var generators = {
[APOLLO_JS_TYPE]: generateApolloJS,
[JS_TYPE]: generateJs,
[JSON_TYPE]: generateJson,
};

Expand All @@ -32,7 +32,7 @@ function generateClient(clientName, nameToAlias, type) {
}).join(",")
keyValuePairs += "\n}"

generateOutfile = generators[type || APOLLO_JS_TYPE];
generateOutfile = generators[type || JS_TYPE];

if (!generateOutfile) {
throw new Error("Unknown generator type " + type + " encountered for generating the outFile");
Expand All @@ -43,6 +43,6 @@ function generateClient(clientName, nameToAlias, type) {

module.exports = {
generateClient,
APOLLO_JS_TYPE,
JS_TYPE,
JSON_TYPE,
}
2 changes: 1 addition & 1 deletion javascript_client/sync/index.js
Expand Up @@ -21,7 +21,7 @@ var fs = require("fs")
* @param {String} options.mode - If `"file"`, treat each file separately. If `"project"`, concatenate all files and extract each operation. If `"relay"`, treat it as relay-compiler output
* @param {Boolean} options.addTypename - Indicates if the "__typename" field are automatically added to your queries
* @param {String} options.outfile - Where the generated code should be written
* @param {String} options.outfileType - The type of the generated code (i.e., json, apollo-js)
* @param {String} options.outfileType - The type of the generated code (i.e., json, js)
* @param {String} options.client - the Client ID that these operations belong to
* @param {Function} options.send - A function for sending the payload to the server, with the signature `options.send(payload)`. (Default is an HTTP `POST` request)
* @param {Function} options.hash - A custom hash function for query strings with the signature `options.hash(string) => digest` (Default is `md5(string) => digest`)
Expand Down

0 comments on commit 4328dda

Please sign in to comment.