Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Schema->getSignature() #343

Conversation

chillu
Copy link
Member

@chillu chillu commented Dec 16, 2020

It's not used anywhere, and is "false advertisement"
since there's a whole lot of instance state which it doesn't cover
(e.g. procedural addType() calls, anything in SchemaContext).
If there was a reason to keep it, we shouldn't return a potentially
huge string as a signature, but rather use a hash.
This would also avoid accidentally disclosing potentially
sensitive (serialised) data in cache keys etc.

It's not used anywhere, and is "false advertisement"
since there's a whole lot of instance state which it doesn't cover
(e.g. procedural addType() calls, anything in SchemaContext).
If there was a reason to keep it, we shouldn't return a potentially
huge string as a signature, but rather use a hash.
This would also avoid accidentally disclosing potentially
sensitive (serialised) data in cache keys etc.
chillu added a commit to unclecheese/silverstripe-graphql that referenced this pull request Dec 16, 2020
The schema is used for two purposes:
1. Building: It converts config arrays (retrieved from YAML) to instance state, which is required to call `save()` and persist the schema for later use.
2. Fetching: It loads retrieves an existing persisted schema. This does not require any instance state.

`bootConfig()` was called in the constructor, and implied that it prepares the instance for operation. In fact, it only merges enough (global and local) config to set up a SchemaContext object. It does not validate the schema, or build out the instance state (types, models, etc).. At this point, the instance can be used for *some* operations such as retrieving the underlying GraphQL schema (via `fetch()`). This benefitted the main `Controller` use because other instance state is expensive to validate and create from config (via `applyConfig()`). In order to *actually* get a consistent schema (reflecting the YAML configuration), you also needed to call `loadFromConfig()`.

This change centralises the two step process (bootConfig, loadFromConfig) into a single one with an obvious name: `boot()`.
It also removes the need to store the intermediary merged config state on the instance, which is only required for diagnostic purposes and complicates state management.
Since the config state getter was removed, it also required removal of getSignature() - see silverstripe#343

Context: silverstripe#335 (comment)
unclecheese pushed a commit to unclecheese/silverstripe-graphql that referenced this pull request Jan 17, 2021
The schema is used for two purposes:
1. Building: It converts config arrays (retrieved from YAML) to instance state, which is required to call `save()` and persist the schema for later use.
2. Fetching: It loads retrieves an existing persisted schema. This does not require any instance state.

`bootConfig()` was called in the constructor, and implied that it prepares the instance for operation. In fact, it only merges enough (global and local) config to set up a SchemaContext object. It does not validate the schema, or build out the instance state (types, models, etc).. At this point, the instance can be used for *some* operations such as retrieving the underlying GraphQL schema (via `fetch()`). This benefitted the main `Controller` use because other instance state is expensive to validate and create from config (via `applyConfig()`). In order to *actually* get a consistent schema (reflecting the YAML configuration), you also needed to call `loadFromConfig()`.

This change centralises the two step process (bootConfig, loadFromConfig) into a single one with an obvious name: `boot()`.
It also removes the need to store the intermediary merged config state on the instance, which is only required for diagnostic purposes and complicates state management.
Since the config state getter was removed, it also required removal of getSignature() - see silverstripe#343

Context: silverstripe#335 (comment)
@unclecheese unclecheese merged commit ea13dbc into silverstripe:master Jan 20, 2021
chillu added a commit to unclecheese/silverstripe-graphql that referenced this pull request Jan 20, 2021
The schema is used for two purposes:
1. Building: It converts config arrays (retrieved from YAML) to instance state, which is required to call `save()` and persist the schema for later use.
2. Fetching: It loads retrieves an existing persisted schema. This does not require any instance state.

`bootConfig()` was called in the constructor, and implied that it prepares the instance for operation. In fact, it only merges enough (global and local) config to set up a SchemaContext object. It does not validate the schema, or build out the instance state (types, models, etc).. At this point, the instance can be used for *some* operations such as retrieving the underlying GraphQL schema (via `fetch()`). This benefitted the main `Controller` use because other instance state is expensive to validate and create from config (via `applyConfig()`). In order to *actually* get a consistent schema (reflecting the YAML configuration), you also needed to call `loadFromConfig()`.

This change centralises the two step process (bootConfig, loadFromConfig) into a single one with an obvious name: `boot()`.
It also removes the need to store the intermediary merged config state on the instance, which is only required for diagnostic purposes and complicates state management.
Since the config state getter was removed, it also required removal of getSignature() - see silverstripe#343

Context: silverstripe#335 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants