VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.89k forks source link

collection.addField not working if schema is simpl-schema #2708

Open EloyID opened 3 years ago

EloyID commented 3 years ago

Describe the bug If I create a collection using a schema which is instance of simpl-schema and then I use addField, it won't appear in GraphQL

To Reproduce Steps to reproduce the behavior:

  1. Create a collection using simpl-schema in the schema
  2. Use collection.addField
  3. Try to query/filter by this field

Expected behavior The field to exist

ErikDakoda commented 3 years ago

Try this:

  collection.attachSchema({
    addedField1: {
      type: Boolean,
      . . .
    },
    addedField2: {
      type: Object,
      . . .
    },
  });
EloyID commented 3 years ago

It's already in the addField function and it used to work in the release of november https://github.com/VulcanJS/Vulcan/blob/f5012d16ab272c753efbc159ca44fb829f362f46/packages/vulcan-lib/lib/modules/collections.js#L76-L89

ErikDakoda commented 3 years ago

@EloyID there is a bug in addField that I attempted to fix with a PR but the change was reverted by @SachaG. Here is our discussion about it: https://github.com/VulcanJS/Vulcan/pull/2648 . My solution above is the workaround I am using.