src/custom.js
function parseSchemaDirectives(directives) {
  let schemaDirectives = [];

  if (
    !directives ||
    !(directives instanceof Object) ||
    Object.keys(directives).length === 0
  ) {
    return [];
  }

  for (let directiveName in directives) {
    let argsList = [],
      args = '';

    Object.keys(directives[directiveName]).map(key => {
      argsList.push(`${key}:"${directives[directiveName][key]}"`);
    });

    if (argsList.length > 0) {
      args = `(${argsList.join(',')})`;
    }

    schemaDirectives.push(`@${directiveName}${args}`);
  }

  return parse(`{ a: String ${schemaDirectives.join(' ')} }`).definitions[0]
    .selectionSet.selections[0].directives;
}
function parseSchemaDirectives(directives) {
  let schemaDirectives = [];

  if (
    !directives ||
    !(directives instanceof Object) ||
    Object.keys(directives).length === 0
  ) {
    return [];
  }

  for (let directiveName in directives) {
    let argsList = [],
      args = '';

    Object.keys(directives[directiveName]).map(key => {
      argsList.push(`${key}:"${directives[directiveName][key]}"`);
    });

    if (argsList.length > 0) {
      args = `(${argsList.join(',')})`;
    }

    schemaDirectives.push(`@${directiveName}${args}`);
  }

  return parse(`{ a: String ${schemaDirectives.join(' ')} }`).definitions[0]
    .selectionSet.selections[0].directives;
}
function parseSchemaDirectives ( directives ) { let schemaDirectives = [ ] ; if ( ! directives || ! ( directives instanceof Object ) || Object . keys ( directives ) . length === 0 ) { return [ ] ; } for ( let directiveName in directives ) { let argsList = [ ] , args = '' ; Object . keys ( directives [ directiveName ] ) . map ( key => { argsList . push ( ` ${ key } ${ directives [ directiveName ] [ key ] } ` ) ; } ) ; if ( argsList . length > 0 ) { args = ` ${ argsList . join ( ',' ) } ` ; } schemaDirectives . push ( ` ${ directiveName } ${ args } ` ) ; } return parse ( ` ${ schemaDirectives . join ( ' ' ) } ` ) . definitions [ 0 ] . selectionSet . selections [ 0 ] . directives ; }
parse directives from a schema defenition form them as graphql directive structure
parse directives from a schema defenition form them as graphql directive structure