Skip to content

Commit

Permalink
Merge branch 'master' into remove-unused
Browse files Browse the repository at this point in the history
  • Loading branch information
timleslie authored Sep 1, 2020
2 parents d9d1ca7 + 234627a commit ddfc692
Show file tree
Hide file tree
Showing 185 changed files with 1,781 additions and 972 deletions.
8 changes: 8 additions & 0 deletions .changeset/breezy-forks-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@keystonejs/cypress-project-access-control": patch
"@keystonejs/cypress-project-basic": patch
"@keystonejs/cypress-project-client-validation": patch
"@keystonejs/cypress-project-login": patch
---

Updated dependency `mocha` to `^7.2.0`.
8 changes: 8 additions & 0 deletions .changeset/cool-humans-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@keystonejs/cypress-project-access-control": patch
"@keystonejs/cypress-project-basic": patch
"@keystonejs/cypress-project-client-validation": patch
"@keystonejs/cypress-project-login": patch
---

Updated dependency `cypress-multi-reporters` to `^1.4.0`.
11 changes: 11 additions & 0 deletions .changeset/eight-avocados-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@keystonejs/app-admin-ui": patch
"@keystonejs/app-graphql": patch
"@keystonejs/fields": patch
"@keystonejs/keystone": patch
"@keystonejs/demo-project-blog": patch
"@keystonejs/demo-project-meetup": patch
"@keystonejs/cypress-project-basic": patch
---

Updated dependency `graphql` to `^14.7.0`.
5 changes: 5 additions & 0 deletions .changeset/eleven-hounds-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/adapter-knex": patch
---

Updated dependency `knex` to `^0.21.5`.
5 changes: 5 additions & 0 deletions .changeset/forty-ravens-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/app-admin-ui": patch
---

Updated dependency `webpack` to `v4.44.1`.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-buckets-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/file-adapters": patch
---

Updated dependency `cloudinary` to `^1.23.0`.
5 changes: 5 additions & 0 deletions .changeset/happy-cycles-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/website": patch
---

Updated dependency `@reach/skip-nav` to `^0.10.5`.
6 changes: 6 additions & 0 deletions .changeset/happy-eggs-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@keystonejs/apollo-helpers": patch
"@keystonejs/app-admin-ui": patch
---

Updated dependency `@types/react` to `^16.9.48`.
7 changes: 7 additions & 0 deletions .changeset/hungry-moons-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@keystonejs/cypress-project-access-control": patch
"@keystonejs/cypress-project-basic": patch
"@keystonejs/cypress-project-login": patch
---

Updated dependency `cypress-file-upload` to `^3.5.3`.
5 changes: 5 additions & 0 deletions .changeset/kind-tips-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/app-admin-ui": patch
---

Updated dependency `html-webpack-plugin` to `^4.4.1`.
5 changes: 5 additions & 0 deletions .changeset/lemon-avocados-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/website": patch
---

Updated dependency `gatsby-remark-check-links` to `^2.1.0`.
10 changes: 10 additions & 0 deletions .changeset/lemon-hotels-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@keystonejs/fields-cloudinary-image": patch
"@keystonejs/fields-location-google": patch
"@keystonejs/fields-oembed": patch
"@keystonejs/fields-unsplash": patch
"@keystonejs/fields": patch
"@keystonejs/demo-project-blog": patch
---

Updated dependency `node-fetch` to `^2.6.0`.
5 changes: 5 additions & 0 deletions .changeset/olive-dolls-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/adapter-knex": patch
---

Updated dependency `pg` to `^8.3.3`.
5 changes: 5 additions & 0 deletions .changeset/pink-nails-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/website": patch
---

Updated dependency `get-workspaces` to `^0.5.2`.
5 changes: 5 additions & 0 deletions .changeset/popular-kangaroos-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystonejs/keystone": patch
---

Updated dependency `endent` to `^1.4.1`.
8 changes: 8 additions & 0 deletions .changeset/sixty-garlics-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@keystonejs/demo-project-blog': patch
'@keystonejs/demo-custom-fields': patch
'@keystonejs/demo-project-meetup': patch
'@keystonejs/demo-project-todo': patch
---

Renamed `demo-projects` folder to `examples` to allow for future smaller focused examples.
10 changes: 10 additions & 0 deletions .changeset/tame-lies-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@keystonejs/app-admin-ui": patch
"@keystonejs/fields-unsplash": patch
"@keystonejs/fields": patch
"@keystonejs/keystone": patch
"@keystonejs/demo-project-blog": patch
"@keystonejs/demo-project-meetup": patch
---

Updated Apollo GraphQL packages dependencies.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
packages/test-project/public
demo-projects/test-project
examples/test-project

# Logs
logs
Expand Down
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ coverage
packages/test-project/public
website/.cache/**/*
website/public/**/*
demo-projects/todo/.cache
demo-projects/blog/app/.next
examples/todo/.cache
examples/blog/app/.next
packages/arch/www/public/**/*
.changeset/**/*
**/dist
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ We'd like to start by thanking all our wonderful contributors:
These projects are designed to show off different aspects of KeystoneJS features
at a range of complexities (from a simple Todo App to a complex Meetup Site).

See the [`demo-projects/README.md`](/demo-projects/README.md) docs to get
See the [`examples/README.md`](/examples/README.md) docs to get
started.

### Development Practices
Expand Down Expand Up @@ -190,7 +190,7 @@ yarn
yarn dev
```

See [`demo-projects/README.md`](/demo-projects/README.md) for more details on
See [`examples/README.md`](/examples/README.md) for more details on
the available demo projects.

#### Note For Windows Users
Expand Down
2 changes: 1 addition & 1 deletion api-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@keystonejs/session": "*",
"cookie-signature": "^1.1.0",
"globby": "^11.0.1",
"superagent": "^6.0.0",
"superagent": "^6.1.0",
"supertest-light": "^1.0.3",
"testcheck": "^1.0.0-rc.2"
},
Expand Down
96 changes: 96 additions & 0 deletions docs/blog/field-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!--[meta]
section: blog
title: Field types in Keystone
date: 2020-08-03
author: Mike Riethmuller
[meta]-->

# Field types

Field types in Keystone sit at the intersection of the Database, GraphQL API and User Interface. When you select and configure a field type, you are specifying how data is stored, how types in GraphQL are defined, and how the interface looks in the Admin app.

To give an example, the `Text` field creates a `TEXT` column in a Postgres database, and a `String` type in a MongoDb schema. It has a return type of `String` in the GraphQL API, and an input type (for mutations) also of `String`. The interface produces a styled `<input />` element or a `<textarea />` depending on if the `isMultiline` option is configured.

For a complete technical breakdown on the anatomy of field types and how they are built, see the [custom field type guide](/docs/guides/custom-field-types.md).

Because they sit at this intersection of concerns, it can be difficult to decide what customisations should become new field types. How many concerns need to differ before creating a new field vs adding config options or project specific customsation such as hooks?

This post provides insight into how we think about field types. Broadly speaking, field types can be grouped into one of two categories. Core field types and Non-Core field types.

## Core field types

Core field types are those included in the `@keystonejs/fields` package and fall under ths `@keystonejs/fields-*` namespace.

There's no definitive guide as to when a field should be a core field type, but generally speaking, the core fields consist of "primitive" values like:

- `Text`,
- `Number`,
- `DateTime` etc,

These usually map fairly well to primitive data types common to many programming languages and databases. However Keystone is a CMS and essential types for CMS applications extend beyond data types.

For these reasons we also consider more complex fields such as: `Select`, and `Relationship` as core field types.

## Non-core field types

If a core field represents a primitive value or common type of structured data use in applications, non-core types could be considered flavours on top of these.

A good example is the `Markdown` field. It stores values in the same way as the `Text` field. Technically speaking it's just an extension of the `Text` field that replaces the field view in the Admin UI.

Given this, it's reasonable to ask why have a new field type at all? Why not have an option on the `Text` field, similar to `isMultiline`? Both examples change the UI without changing anything about how the data is stored in the database or handled in GraphQL.

Although technically similar to the `Text` field, conceptually, `Markdown` represents a different content type. You would not arbitrarily display any text as `Markdown` in the same way you might with a multiline input.

This completes the basic criteria of how we decide on new field types over config options or project specific customsation:

1. Is data in the Database or GraphQL a different type?
1. Is it conceptually a different field type for users?
1. Is the UI incompatible with other values using the same type?

It's also important to note that`Markdown` includes `codemirror` - a sizeable third-party library used to provide a nice editor interface. We don't want to bundle `codemirror` with the core fields package, especially when a `Markdown` field is not an essential to a large majority of Keystone projects.

This forms the final part of the decision making to help determine when a field is a non-core field type. Non-core field types often:

1. share a primitive type, data structure, or use-case with a core field
1. are not required for many Keystone projects
1. connect with a third-party service or API
1. include a third-party library, that will impact the core fields bundle

It may be open to some interpretation, but the above guidelines help when deciding which fields belong with `@keystonejs/fields` package, and which don't.

## The future of field types

After reviewing existing fields and applying the above decision making process retrospectively, it highlights a few places we got this wrong in the past.

We've realised the following field types are non-core field types:

- `CloudinaryImage`
- `OEmbed`
- `UnSplash`
- `Location`

These will be moved out of the core fields package.

We've also realised that the `AuthedRelationship` is not conceptually different to the standard `Relationship` field. It doesn't store or handle data differently. It provides a shortcut for a common use-case of setting the value of the of a `Relationship` field to the currently authenticated user is a common use-case.

This functionality can be achieved with hooks and config on the existing `Relationship` field. We plan to document how to achieve common use-cases such as this before changing the `AuthedRelationship` field.

The `@keystonejs/fields-date-utc` package should be moved into the core fields package. It's a primitive data type used in a wide range of projects.

Both `Color` and `Url` are interesting. They currently both store values in the same way as the `Text` field and do nothing more than change the view.

The `Url` field only sets the HTML `type` attribute on the input element. You could add an option like is `isURL`, similar to the `isMultiline` and the same argument could be made for an option that allows setting the `type` attribute to "email".

An option should be added to the `Text` field that allows setting the HTML `type` attribute to either `url`, `email` or `text` (default).

However, much like `Markdown`, `URL` and `Email` are conceptually different fields for many users. It makes sense to expand the configuration options for `Text`, but there is also an argument for a unique field type that uses knowledge of the structure of URLs and emails to implement specific features. Examples might include server-side validation, domain based filtering, case-insensitive unique restrictions.

We won't deprecate or move the `URL` field for now but will look to improve it's implementation over time.

The `Location` and `Color` fields bundles a third-party libraries and are not a common requirement for many projects. Both should be moved out of the core packages.

Expect to see fields move between the core and non-core packages over the next few weeks. In the longer term hope to improve functionality of existing field in some of the ways mentioned here. We also hope this provides clarity around the choices we have made with field types.

If you want to continue the discussion head over to our [community Slack channel](https://community.keystonejs.com/) and ask us about field types. You can tweet at us [@KeystoneJS on Twitter](https://twitter.com/KeystoneJS).

Finally if you have a custom field type, please share it with us! We might include it in the Keystone or one of our contributors, Gautam Singh, maintains the `@keystonejs-contrib` namespace for any other community contributions.
2 changes: 1 addition & 1 deletion docs/guides/custom-field-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Type/views/

## Example

For an example of a custom field, please see the [Stars field](https://github.com/keystonejs/keystone/tree/master/demo-projects/custom-fields/) in the basic test project.
For an example of a custom field, please see the [Stars field](https://github.com/keystonejs/keystone/tree/master/examples/custom-fields/) in the basic test project.

## Implementation

Expand Down
4 changes: 0 additions & 4 deletions docs/guides/mutation-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ Each of these mutations is implemented within Keystone by a corresponding resolv
| `updateUsers` || `updateManyMutation` |
| `deleteUsers` || `deleteManyMutation` |

<!-- Dead links
Please refer to the [API documentation](LINK_TODO)) for full details on how to call these mutations either from [GraphQL](LINK_TODO)) or directly from [Keystone](LINK_TODO)).
-->

Keystone provides [access control](/docs/guides/access-control.md) mechanisms and a [hook system](/docs/guides/hooks.md) which allows the developer to customise the behaviour of each of these mutations.

This document details the lifecycle of each mutation, and how the different access control mechanisms and hooks interact.
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/custom-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ The rest of the views relate to React components rendered in the Admin UI. We ca
<Stars count={5} value={3}>
```

You can find an example of this component in the [custom-fields demo project](https://github.com/keystonejs/keystone/tree/master/demo-projects/custom-fields/fields/Stars/views/Stars.js).
You can find an example of this component in the [custom-fields demo project](https://github.com/keystonejs/keystone/tree/master/examples/custom-fields/fields/Stars/views/Stars.js).

Once we have a component for star ratings we can use this in Keystone.

Expand Down Expand Up @@ -149,4 +149,4 @@ That's it, we now have a basic custom field.

## Next Steps

Take a look at this example and others in the [custom-fields demo project](https://github.com/keystonejs/keystone/tree/master/demo-projects/custom-fields/) in the Keystone repository.
Take a look at this example and others in the [custom-fields demo project](https://github.com/keystonejs/keystone/tree/master/examples/custom-fields/) in the Keystone repository.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"start": "cross-env NODE_ENV=production keystone start"
},
"dependencies": {
"@apollo/client": "^3.1.3",
"@apollo/client": "^3.1.4",
"@arch-ui/layout": "^0.2.14",
"@arch-ui/typography": "^0.0.18",
"@emotion/core": "^10.0.35",
Expand All @@ -38,12 +38,12 @@
"date-fns": "^2.15.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"graphql": "^14.6.0",
"graphql": "^14.7.0",
"isomorphic-unfetch": "^3.0.0",
"next": "^9.5.2",
"node-fetch": "^2.3.0",
"node-fetch": "^2.6.0",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"repository": "https://github.com/keystonejs/keystone/tree/master/demo-projects/blog"
"repository": "https://github.com/keystonejs/keystone/tree/master/examples/blog"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"cross-env": "^7.0.2",
"react": "^16.13.1"
},
"repository": "https://github.com/keystonejs/keystone/tree/master/demo-projects/custom-fields"
"repository": "https://github.com/keystonejs/keystone/tree/master/examples/custom-fields"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const MEETUP = {
copyrightText: `
<p>Copyright &copy; Thinkmill Pty Ltd, powered by <a href="https://keystonejs.com">KeystoneJS</a>.</p>
<p>If you run a meetup, please feel free to clone our site and make your own!
<a href="https://github.com/keystonejs/keystone/tree/master/demo-projects/meetup">You can find it on GitHub</a>.
<a href="https://github.com/keystonejs/keystone/tree/master/examples/meetup">You can find it on GitHub</a>.
</p>
`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"start": "cross-env NODE_ENV=production keystone start"
},
"dependencies": {
"@apollo/client": "^3.1.3",
"@apollo/client": "^3.1.4",
"@emotion/core": "^10.0.35",
"@keystonejs/adapter-mongoose": "^9.0.4",
"@keystonejs/app-admin-ui": "^7.3.3",
Expand All @@ -37,7 +37,7 @@
"express": "^4.17.1",
"facepaint": "^1.2.1",
"get-contrast": "^2.0.0",
"graphql": "^14.6.0",
"graphql": "^14.7.0",
"isomorphic-unfetch": "^3.0.0",
"lodash.uniqby": "^4.7.0",
"next": "^9.5.2",
Expand All @@ -48,5 +48,5 @@
"react-use-form-state": "^0.13.1",
"uuid": "^8.3.0"
},
"repository": "https://github.com/keystonejs/keystone/tree/master/demo-projects/meetup"
"repository": "https://github.com/keystonejs/keystone/tree/master/examples/meetup"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions demo-projects/todo/.gitignore → examples/todo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ tags
# End of https://www.gitignore.io/api/vim

temp/
/public
/dist
dist/
.cache
.next
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
"@keystonejs/keystone": "^14.0.1",
"cross-env": "^7.0.2"
},
"repository": "https://github.com/keystonejs/keystone/tree/master/demo-projects/todo"
"repository": "https://github.com/keystonejs/keystone/tree/master/examples/todo"
}
File renamed without changes.
Loading

0 comments on commit ddfc692

Please sign in to comment.