How to use the graphql-sequelize.attributeFields function in graphql-sequelize

To help you get started, we’ve selected a few graphql-sequelize 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 birkir / prime / packages / prime-core / src / routes / internal / index.ts View on Github external
export const internalGraphql = async restart => {
  const app = express();

  const contentTypeFieldType = new GraphQLObjectType({
    name: 'ContentTypeField',
    fields: omit(attributeFields(ContentTypeField), ['contentTypeId']),
  });

  const userType = new GraphQLObjectType({
    name: 'User',
    fields: {
      ...omit(attributeFields(User), ['password']),
      roles: { type: new GraphQLList(GraphQLString) },
    },
  });

  const contentTypeType = new GraphQLObjectType({
    name: 'ContentType',
    fields: () => ({
      ...attributeFields(ContentType),
      schema: {
        type: new GraphQLList(ContentTypeFieldGroup),
github birkir / prime / packages / prime-core / src / routes / internal / index.ts View on Github external
entriesCount: { type: GraphQLInt },
    }),
  });

  const contentReleaseType = new GraphQLObjectType({
    name: 'ContentRelease',
    fields: () => ({
      ...attributeFields(ContentRelease),
      documents: { type: GraphQLInt },
    }),
  });

  const contentEntryType = new GraphQLObjectType({
    name: 'ContentEntry',
    fields: omit({
      ...attributeFields(ContentEntry),
      contentType: {
        type: contentTypeType,
        resolve: resolver(ContentType, {
          before(opts, args, context, info) {
            opts.where = {
              id: info.source.contentTypeId,
            };

            return opts;
          },
        }),
      },
      user: {
        type: userType,
        resolve: resolver(User, {
          before(opts, args, context, info) {
github oughtinc / mosaic / server / lib / schema / index.ts View on Github external
fields: () =>
      _.assign(
        attributeFields(model),
        generateReferences(references),
        extraFields,
      ),
  });
github oughtinc / mosaic / server / lib / schema / index.ts View on Github external
    fields: () => _.assign(attributeFields(model), generateReferences(model, references), extraFields)
  })
github oughtinc / mosaic / server / lib / schema / index.ts View on Github external
},
);

const pointerType = makeObjectType(Pointer, [
  ["pointerImport", () => pointerImportType],
  ["sourceBlock", () => blockType],
]);

const pointerImportType = makeObjectType(PointerImport, [
  ["workspace", () => blockType],
  ["pointer", () => pointerType],
]);

const BlockInput = new GraphQLInputObjectType({
  name: "blockInput",
  fields: _.pick(attributeFields(Block), "value", "id"),
});

const TreeInputForAPI = new GraphQLInputObjectType({
  name: "treeInputForAPI",
  fields: {
    rootLevelQuestion: { type: GraphQLString },
    rootLevelScratchpad: { type: GraphQLString },
    honestAnswer: { type: GraphQLString },
    maliciousAnswer: { type: GraphQLString },
    emailsOfHonestOracles: { type: new GraphQLList(GraphQLString) },
    emailsOfMaliciousOracles: { type: new GraphQLList(GraphQLString) },
    doesAllowJudgeToJudge: { type: GraphQLBoolean },
    isMIBWithoutRestarts: { type: GraphQLBoolean },
    schedulingPriority: { type: GraphQLInt },
    depthLimit: { type: GraphQLInt },
  },
github birkir / prime / packages / prime-core / src / routes / internal / types / Webhook.ts View on Github external
fields: () => ({
    ...attributeFields(WebhookModel),
    success: { type: GraphQLInt },
    count: { type: GraphQLInt },
  }),
});
github bradleyboy / tuql / src / builders / schema.js View on Github external
fields() {
          const fields = attributeFields(model);

          fieldAssociations.hasMany.forEach(associatedModel => {
            fields[formatFieldName(associatedModel.name)] = {
              type: new GraphQLList(types[associatedModel.name]),
              args: defaultListArgs(model[associatedModel.name]),
              resolve: resolver(model[associatedModel.name]),
            };
          });

          fieldAssociations.belongsTo.forEach(associatedModel => {
            const fieldName = singular(associatedModel.name);
            fields[formatFieldName(fieldName)] = {
              type: types[associatedModel.name],
              resolve: resolver(model[fieldName]),
            };
          });
github bradleyboy / tuql / src / builders / arguments.js View on Github external
export const makeUpdateArgs = model => {
  const fields = attributeFields(model);

  return Object.keys(fields).reduce((acc, key) => {
    const field = fields[key];

    if (field.type instanceof GraphQLNonNull) {
      field.type = field.type.ofType;
    }

    acc[key] = field;
    return acc;
  }, fields);
};
github bradleyboy / tuql / src / builders / arguments.js View on Github external
export const makePolyArgs = (model, otherModel) => {
  const [key, otherKey, otherKeyFormatted] = getPolyKeys(model, otherModel);
  const fields = attributeFields(model);
  const otherFields = attributeFields(otherModel);

  return {
    [key]: fields[key],
    [otherKeyFormatted]: otherFields[otherKey],
  };
};