Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Be nice(r) when no arguments given #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ExtractGQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export const main = (argv: YArgsv) => {

if (args.length < 1) {
console.log('Usage: persistgraphql input_file [output_file]');
process.exit(1);
} else if (args.length === 1) {
inputFilePath = args[0];
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/network_interface/ApolloNetworkInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export function addPersistedQueries(networkInterface: NetworkInterface, queryMap
return Object.assign(networkInterface, {
query: (request: Request): Promise<ExecutionResult> => {
const queryDocument = request.query;

if (queryDocument === undefined) {
return Promise.reject(new Error('No query document was provided'));
}

const queryKey = getQueryDocumentKey(queryDocument);

if (!queryMap[queryKey]) {
Expand Down