mickhansen / graphql-sequelize

GraphQL & Relay for MySQL & Postgres via Sequelize
MIT License
1.9k stars 172 forks source link

Cache enum types in attributeFields doesn't work as expected #646

Closed alirizwan closed 5 years ago

alirizwan commented 5 years ago

When calling attribute fields multiple times on same model, duplicate enumtypes gets created with an error: Error: Schema must contain unique named types but contains multiple types named "UserroleEnumType".

mcouthon commented 4 years ago

Why was this closed? This still seems like an existing bug.

mcouthon commented 4 years ago

Actually, I solved it by doing this:

const options = {
    cache: {},
    commentToDescription: true
  };
const fullModel = attributeFields(model, options);
options.allowNull = true;
const looseModel = attributeFields(model, options);
}

Seems to work well