Cosmic JS Changelog

Follow the changelog for product updates and feature roll-outs.

GraphQL API v2 Released 🎉


We're happy to announce the newest version of our GraphQL API. The new Cosmic GraphQL API v2 includes some great updates and improvements which you can read about below.


What you need to know
1. You can stay on v1, but updates and fixes will no longer be made to v1.
2. v2 includes mostly additions, but one breaking change to the getObjects  and getMedia  queries to enable pagination.


Playground
Demo for yourself in the playground. You can use the "Schema" and "Docs" right-side tabs to explore the Model and Queries.

View full page playground


Included in v2

1. Pagination support
You can now access the total and limit  properties from the API response. This gives you the ability to do pagination with the GraphQL API, which was previously not possible.

View full page playground


2. New Queries and Mutations
You can use the GraphQL API to get revisions from an Object as well as add new revisions without affecting the current published state of your Object.

getObjectRevisions
addObjectRevision


View full page playground


3. Deprecated Queries Removed
The following deprecated queries from v1 have been removed:
object
objects
objectsByType


4. Response Format Changes
To allow for the total and limit response, one breaking change had to be made. The response format for getObjects now follows the following format with all Objects moved into a second level objects.

View full page playground


And here's the old way for reference:

View full page playground


5. Search and Filter Options
One of the most loved new features in the REST API is filtering and searching by metadata. This is now available in the GraphQL API. For example, to get Objects that by a certain author. You can do this:

View full page playground


Read more about these updates in the GraphQL documentation. We hope you enjoy these new features with the latest version of the GraphQL API. Any questions or comments? Reach out to us on Twitter and join the conversation on our Slack channel.

Auto Save, Object Revisions Endpoint, and Metafield Bug Fixes


We've got some exciting updates that should make editing and integrating your Cosmic-powered content faster, easier, and more enjoyable. This release includes two updates: 1) a new Auto Save feature, and 2) fixes and enhancements to the Metafield editing experience.


1. Auto Save
We have added a new Auto Save feature, which will automatically save your Object content to draft while you are editing. No need to manually save until you are ready to publish. (This is currently only available if you have revision history enabled)


Customers of Gatsby Preview will love this feature as you will see updates to your Gatsby Cloud link instantaneously!

Auto Save with Gatsby Cloud in action:

click to zoom

2. Object Revisions Endpoint
You now have revisions available via the API. You can find this endpoint on every Object in the Dashboard when you click the "Revisions" button. View the docs for more info.

click to zoom

3. Metafields (Bug fixes and enhancements)
The Cosmic JS team is dedicated to offering a first-class content editing experience.  With our Metafields content modeling approach, we offer one of the most powerful content management systems available. And we've made this much-loved feature even better.

We're happy to report that we fixed some Metafield bugs reported by the Cosmic JS community as well as added a few enhancements.

Fixes include:

  • Help Text
    • Issues related to repeater & parents have been fixed
  • Select Dropdown
    • A bug with dropdown `key` & `value` issues has been fixed
  • Repeater scroll Issue
    • Edit Page no longer jumps up and down when you add and remove repeater items

Enhancements include:

  • Duplicate Metafield
    • Now when you duplicate Metafields, it will append a unique `key` identifier
  • Unique Metafield keys
    • Metafield keys are now required to be unique. This fixes quite a few issues that came up from Metafields clashing or not showing up in the API


Any questions or comments? Reach out to us on Twitter and join the conversation on our Slack channel.

Infrastructure Upgrade, New Metafields, and more


This changelog announcement is a big one for us and includes:

  1. Upgraded infrastructure
  2. New Metafields and
  3. Optimizations to our open source clients.


1. Infrastructure Upgrade

We're happy to tell you that all Cosmic JS components are now powered 100% by serverless technologies. By running completely even-driven using AWS Lambda functions, the REST API, GraphQL API, Dashboard application, and the website are now infinitely scalable through high traffic loads.

This is huge, because it means you can depend on us to deliver your content through the highest traffic loads with dynamic server capacity on demand. This is also big for the Cosmic JS team, because we are now able to make product improvements at a higher velocity with a more streamlined deployment process.

We have also added a caching service to our website to serve our website resources at the edge. Your team can now get to any resource on cosmicjs.com faster and easier with at least 10x faster page loading from any spot on the globe.



2. New Metafields

We have added Boolean Switch and Number Metafields to our list of available Metafield types. We recommend that if you are using Text Metafields for either of these value types, that you switch to these new Metafields.

New Switch Metafield in action:



3. Open Source Optimizations

We've added additional optimizations to our popular Cosmic JS NPM module and Gatsby source plugin. By adding the Accept-Encoding: gzip header to encode responses, API load times and payload sizes have been cut in half. Install the latest versions of these libraries to get this improvement (3.2.35 and 1.0.4 respectively).


We're on a mission to build the best CMS on the planet, and your feedback helps! If you have any questions or feature requests, reach out to us on Twitter, and join our Slack channel. Happy building!

Filters and Smart Views


We're excited to release a new feature that should be a huge time-saver for finding and using your Bucket content: Filters and Smart Views. You can now filter and save smart views in your Objects table view in the Dashboard.

Filter and Save Smart View

Check it out by logging in and going to any Object Type in your Bucket. 


Filters
Click the "Filters" button on any Object Type table view in the Dashboard. Filter Objects by:

  • Status
  • Created by
  • Metadata


Smart views
You can then save your filtered content into "Smart Views" that will be added to the sidebar of your Bucket dashboard for easy access. Save for just yourself, or for your whole team.


API Filtering
After filtering, click the "Developer Tools" button to then get the API REST request and NPM module code for your filter options. Metadata filters are available in the latest NPM module v3.2.31. Read more about all NPM and API options in the Cosmic jS docs.

It looks like this:

I hope you enjoy the new capabilities. This feature comes as a direct response to users that needed a better way to find and filter content.

If you have any questions or update that you would like to see shipped, please reach out to us on Twitter and join the conversation on Slack.

Customize REST API Response, Object Metafields Search


We've got a couple updates to make editing and integrating your Cosmic-powered content faster and easier.

1. Customize API Response Data
You can now add a query parameter (props) to the REST API (or NPM module) to limit the response data to only selected properties. Think of this like GraphQL-ifying your REST response to get only the data you need.

For example here's the old way to get Objects from the REST API which gives you everything:

https://api.cosmicjs.com/v1/simple-react-blog/objects?pretty=true&hide_metafields=true&type=posts&limit=20

And now the same query with added props query parameter.

https://api.cosmicjs.com/v1/simple-react-blog/objects?pretty=true&hide_metafields=true&type=posts&limit=20&props=slug,title,content

As you can see, adding props to your query makes your response much more concise giving you only the data you need. This should make your API responses faster, giving you and your end users a better experience 😎

Note: You can also add metadata.your_key to get selected metadata values (limited to one level only).

We've also updated the "Developer Tools" modal in the Dashboard to check out what this looks like:


UPDATE: 9/10/2019
You can also limit the depth of your response data by adding the query param depth. This will limit the nested depth of Object Metafields.

Check out the updated REST API docs for more info.


2. Search Objects in Object Metafields
One of our most popular features is the ability to connect Objects to each other to create relationships. For example: Blog Posts may need to connect to Categories and Authors which you can accomplish using Object Relationship Metafields.

It's now much easier to find the Object you're looking for with a new search feature on the Object Select modal. Simply type in a keyword to quickly find the Objects you need. Gif below:

Updates to Scheduled Publishing


We have a quick update to scheduled publishing that should make things easier for those using this handy feature.

How scheduled publishing used to work:

You set your scheduled publish day and time and it sets your content to draft. This was fine for new content, but not ideal for already published content. If you wanted to maintain your published content and save a new draft for later scheduled update this didn't work.

The new way:
You can now save a published version AND save a draft version scheduled for later publish. This also makes it possible to keep two versions running: 1) Your published content and 2) your draft content scheduled for publish later.

I hope you like this update to scheduled publishing. This update was shipped in direct response to a user that needed a better experience with this feature.

If you have any questions or update that you would like to see shipped, please reach out to us on Twitter and join the conversation on Slack.

Edit Object Metafields


You can now edit specific Metafields on existing Objects via the API. The following API method allows you to edit specific Metafields identified by key, without affecting other Metafields as well as add new Metafields. View in the docs.

The endpoint is:

PATCH https://api.cosmicjs.com/v1/:bucket_slug/edit-object-metafields

Body properties:

slug (String)
metafields (Array)


The Cosmic JS NPM module is also updated (3.2.19) to allow for this capability with the new method:

bucket.editObjectMetafields()

Further directions are available in the Metafields section in the REST API documentation.


Let me know if you have any questions. Join us on Slack and on Twitter.

Updates: New Webhook Event, Delete all Objects in Type, Export Options


New Webhook Event
We have added a new webhook event:

object.edited.unpublished

If you relied on "object.edited.draft" for this event, you will need to edit your webhook to this event. Find your webhooks in Bucket Settings > Webhooks. Be sure to check this out in the Webhooks documentation.


Delete all Objects in your Object Type
This experience has been improved: now when you delete an Object Type it will remove all Objects in this type.


Export Options
You can now export specific Object Types and omit others in your Bucket Export area located in Bucket Settings > Import / Export.

Cosmic JS API now powered by Fastly


We're excited to announce that all Cosmic JS API endpoints (REST and GraphQL) are now powered by the Fastly global CDN. You should now notice huge performance gains on your Bucket API endpoints. For example, if a large endpoint used to take 400ms it is now clocking in under 20ms!

What is Fastly?
Fastly is the leading global CDN cache layer provider that powers some of the most highly-trafficked websites on the internet. The New York Times, Airbnb, and more choose Fastly because of their global CDN of over 60 high-powered point of presence servers (POPs). These POPs are distributed closest to your users so they can get your content as fast as possible. This also shields your cached content from any issues caused by the origin infrastructure.

From the Fastly Network Map page, "we’ve focused our efforts on placing fewer, more powerful POPs at strategic locations around the world."



What does this mean for you?
We're happy to roll this out to all Cosmic JS users. Your Cosmic JS content is now automatically powered by the Fastly global CDN and available to your users world-wide. No extra work needs to be done on your part. Just sit back and notice huge performance gains for you and your users 😎 

And more great news: requests to the cache-served content from the Cosmic JS API will not count towards your API request limits on your billing plan. API requests are counted only on initial requests to any resource after you clear your cache either manually in Bucket > Settings or by adding, editing, or deleting content in your Bucket.

It's our mission to make sure your team has the best experience collaborating on content using Cosmic JS. With the Cosmic JS Fastly update, you can deliver great content and experiences to your world-wide customers even faster.

If you have any questions, reach out to us on Twitter and join the Slack community.