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

Adding Sub Schema #1786

Closed abhirakshit closed 6 years ago

abhirakshit commented 6 years ago

I recently started with VulcanJS. Is it possible to create a sub-schema in Vulcan.

Something which simple schema supports.

const schema = new SimpleSchema({
  name: String,
  homeAddress: addressSchema,
  billingAddress: {
    type: addressSchema,
    optional: true,
  },
});

Thanks

biomassives commented 6 years ago

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its recipients. This is a temporary error. The following address(es) deferred:

acmeideal@gmail.com Domain biomassiv.es has exceeded the max emails per hour (108/100 (108%)) allowed. Message will be reattempted later

------- This is a copy of the message, including all the headers. ------ Received: from github-smtp2-ext6.iad.github.net ([192.30.252.197]:46106 helo=github-smtp2b-ext-cp1-prd.iad.github.net) by chi-server32.websitehostserver.net with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from noreply@github.com) id 1eQctQ-001n1s-Gh for greg@biomassiv.es; Sun, 17 Dec 2017 11:38:28 -0600 Date: Sun, 17 Dec 2017 09:37:47 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1513532267; bh=CjOFlnqwIyAFFfMJlD5VAtWtQXCmORHf3bqIlvj17J4=; h=From:Reply-To:To:Cc:Subject:List-ID:List-Archive:List-Post: List-Unsubscribe:From; b=dlJN/gbvRNoLVtRQV4Uwqja8qIJPhXWD9sExoDa84ujRfL5uSxf61ZRHku8eAbruR GaroePEXDHCjP6x04d+x1LOuwC36AWIDg+QEAuAnhmupnBEL3KNRAZD0NLJbPr3xXw c6vYCSoqPua1zu0OKszlYMbnA5Ty/TfS3H/Gquxs= From: Abhishek Rakshit notifications@github.com Reply-To: VulcanJS/Vulcan reply@reply.github.com To: VulcanJS/Vulcan Vulcan@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Message-ID: VulcanJS/Vulcan/issues/1786@github.com Subject: [VulcanJS/Vulcan] Adding Sub Schema (#1786) Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="--==_mimepart_5a36ab6b47d58_a103fd6fe9bef2837309b"; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: list X-GitHub-Sender: abhirakshit X-GitHub-Recipient: biomassives X-GitHub-Reason: subscribed List-ID: VulcanJS/Vulcan List-Archive: https://github.com/VulcanJS/Vulcan List-Post: mailto:reply@reply.github.com List-Unsubscribe: mailto:unsub+0042d4e251447c52a081cfa34e072dfd7d6451d9f7f171a592cf00000001164e6d6b92a169ce10d9cf79@reply.github.com, https://github.com/notifications/unsubscribe/AELU4rtlMn3-1H6Wpn7Kmk0WqG53OYyGks5tBVFrgaJpZM4REuxa X-Auto-Response-Suppress: All X-GitHub-Recipient-Address: greg@biomassiv.es

----==_mimepart_5a36ab6b47d58_a103fd6fe9bef2837309b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit

I recently started with VulcanJS. Is it possible to create a sub-schema in Vulcan.

Something which simple schema supports.

const schema = new SimpleSchema({
  name: String,
  homeAddress: addressSchema,
  billingAddress: {
    type: addressSchema,
    optional: true,
  },
});

Thanks

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/VulcanJS/Vulcan/issues/1786 ----==_mimepart_5a36ab6b47d58_a103fd6fe9bef2837309b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

I recently started with VulcanJS. Is it possible to create a sub-schema in Vulcan.

Something which simple schema supports.

const schema = new SimpleSchema({
  name: String,
  homeAddress: addressSchema,
  billingAddress: {
    type: addressSchema,
    optional: true,
  },
});

Thanks


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

----==_mimepart_5a36ab6b47d58_a103fd6fe9bef2837309b--

SachaG commented 6 years ago

Yes, with the caveats that

1) Sub-schemas will not work with automated form generation (you have to define your own custom component to handle the form field). 2) Sub-schemas will not work with the automated GraphQL schema generation (you have to create your own GraphQL type or use the JSON type as a blackbox object).

If that sounds like too much work, you can also use a more relational approach. For example in the use case where a user has multiple addresses, you could create a separate Addresses collection with its own schema with a userId property.

abhirakshit commented 6 years ago

Thanks Sascha,

I will probably take the relational approach