How to use ember-graphql-adapter - 10 common examples

To help you get started, we’ve selected a few ember-graphql-adapter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alphasights / ember-graphql-adapter / addon / compiler.js View on Github external
compile(model, store, options) {
    options = options || {};

    let operationType = options['operationType']; // TODO: Must be query or mutation
    let operationName = options['operationName'];
    let operation = new Operation(operationType, operationName);

    let rootFieldQuery = options['rootFieldQuery'] || {};
    let rootFieldName = options['rootFieldName'] || model.modelName;
    let rootFieldAlias = options['rootFieldAlias'];
    let rootField = new Field(rootFieldName, rootFieldAlias, ArgumentSet.fromQuery(rootFieldQuery));

    Parser.parse(model, store, operation, rootField, options);

    return Generator.generate(operation);
  }
};
github alphasights / ember-graphql-adapter / addon / compiler.js View on Github external
compile(model, store, options) {
    options = options || {};

    let operationType = options['operationType']; // TODO: Must be query or mutation
    let operationName = options['operationName'];
    let operation = new Operation(operationType, operationName);

    let rootFieldQuery = options['rootFieldQuery'] || {};
    let rootFieldName = options['rootFieldName'] || model.modelName;
    let rootFieldAlias = options['rootFieldAlias'];
    let rootField = new Field(rootFieldName, rootFieldAlias, ArgumentSet.fromQuery(rootFieldQuery));

    Parser.parse(model, store, operation, rootField, options);

    return Generator.generate(operation);
  }
};
github alphasights / ember-graphql-adapter / addon / compiler.js View on Github external
compile(model, store, options) {
    options = options || {};

    let operationType = options['operationType']; // TODO: Must be query or mutation
    let operationName = options['operationName'];
    let operation = new Operation(operationType, operationName);

    let rootFieldQuery = options['rootFieldQuery'] || {};
    let rootFieldName = options['rootFieldName'] || model.modelName;
    let rootFieldAlias = options['rootFieldAlias'];
    let rootField = new Field(rootFieldName, rootFieldAlias, ArgumentSet.fromQuery(rootFieldQuery));

    Parser.parse(model, store, operation, rootField, options);

    return Generator.generate(operation);
  }
};
github alphasights / ember-graphql-adapter / addon / compiler.js View on Github external
compile(model, store, options) {
    options = options || {};

    let operationType = options['operationType']; // TODO: Must be query or mutation
    let operationName = options['operationName'];
    let operation = new Operation(operationType, operationName);

    let rootFieldQuery = options['rootFieldQuery'] || {};
    let rootFieldName = options['rootFieldName'] || model.modelName;
    let rootFieldAlias = options['rootFieldAlias'];
    let rootField = new Field(rootFieldName, rootFieldAlias, ArgumentSet.fromQuery(rootFieldQuery));

    Parser.parse(model, store, operation, rootField, options);

    return Generator.generate(operation);
  }
};
github alphasights / ember-graphql-adapter / tests / helpers / store-double.js View on Github external
this.serializerFor = () => {
    let serializer = new Serializer();
    serializer.store = this;
    return serializer;
  };
}
github alphasights / ember-graphql-adapter / addon / parser.js View on Github external
_buildField(attr) {
    return new Type.Field(this.normalizeCaseFn(attr));
  }
github alphasights / ember-graphql-adapter / addon / parser.js View on Github external
field = new Type.Field(
                this.normalizeCaseFn(relName),
                null,
                new Type.ArgumentSet(),
                new Type.SelectionSet()
              );
              this.agenda.push({ name: relName, model: relModel, field });
            }
          }
          if (field) {
            currentField.selectionSet.push(field);
          }
        });
      }
    } else {
      rootField.selectionSet.push(new Type.Field('id'));
    }

    operation.selectionSet.push(rootField);

    return operation;
  }
github alphasights / ember-graphql-adapter / addon / parser.js View on Github external
currentModel.eachRelationship((relName, relationship) => {
          let field;
          let { type, options } = relationship;

          if (options.async) {
            field = this._buildAsyncRelationship(relName, relationship);
          } else {
            let relModel = store.modelFor(type);
            if (this.visited.indexOf(relName) === -1) {
              field = new Type.Field(
                this.normalizeCaseFn(relName),
                null,
                new Type.ArgumentSet(),
                new Type.SelectionSet()
              );
              this.agenda.push({ name: relName, model: relModel, field });
            }
          }
          if (field) {
            currentField.selectionSet.push(field);
          }
        });
      }
github alphasights / ember-graphql-adapter / addon / generator.js View on Github external
generateArgument({name, value}) {
    if (typeOf(value) === 'string') {
      value = this.wrapInStringTokens(value);
    } else if (typeOf(value) === 'array') {
      value = this.argumentArrayOpeningToken + this.wrapArrayInStringTokens(value) + this.argumentArrayClosingToken;
    } else if (value instanceof SelectionSet || value instanceof ArgumentSet) {
      value = this.argumentObjectOpeningToken + this.generateArgumentSet(value) + this.argumentObjectClosingToken;
    } else if (typeOf(value) === 'object') {
      value = ArgumentSet.fromQuery(value);

      value = this.argumentObjectOpeningToken + this.generateArgumentSet(value) + this.argumentObjectClosingToken;
    }

    return name + this.argumentKeyValueSeparateToken + value;
  },
github alphasights / ember-graphql-adapter / addon / parser.js View on Github external
currentModel.eachRelationship((relName, relationship) => {
          let field;
          let { type, options } = relationship;

          if (options.async) {
            field = this._buildAsyncRelationship(relName, relationship);
          } else {
            let relModel = store.modelFor(type);
            if (this.visited.indexOf(relName) === -1) {
              field = new Type.Field(
                this.normalizeCaseFn(relName),
                null,
                new Type.ArgumentSet(),
                new Type.SelectionSet()
              );
              this.agenda.push({ name: relName, model: relModel, field });
            }
          }
          if (field) {
            currentField.selectionSet.push(field);
          }
        });
      }