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

feat(schema): add schema.middleware #688

Merged
merged 6 commits into from
Apr 21, 2020
Merged

feat(schema): add schema.middleware #688

merged 6 commits into from
Apr 21, 2020

Conversation

Weakky
Copy link
Collaborator

@Weakky Weakky commented Apr 21, 2020

  • docs
  • tests

@Weakky Weakky force-pushed the feat/schema-middleware branch from 756045d to 3e8406a Compare April 21, 2020 14:59
@Weakky Weakky requested a review from jasonkuhrt April 21, 2020 15:00
@Weakky Weakky mentioned this pull request Apr 21, 2020
@@ -83,7 +85,7 @@ export function create(): App {
}

const server = Server.create()
const schemaComponent = Schema.create()
const schemaComponent = Schema.create(__state)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I had being going a direction before where schema would have its own state. Your approach reminds me of a react-ish atomic-state idea. Any particular thoughts here or you just did what first came to you?

@@ -5,7 +5,7 @@ import { mapSettingsToNexusSchemaConfig } from './settings'
let schema: ReturnType<typeof create>

beforeEach(() => {
schema = create()
schema = create({ isWasServerStartCalled: false, plugins: [] })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this part feel like a leak of detail?

const middleware: SchemaInternal['public']['middleware'] = (fn) => {
api.public.use(
NexusSchema.plugin({
// TODO: Do we need to expose the name property?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no?

// todo if caleld after app start, raise a warning (dev), error (prod)
// this will require the component having access to some of the
// framework state.
if (appState.isWasServerStartCalled === true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh this is the key reason to pass down app state, I see. Def. a fair point!

Weakky and others added 3 commits April 21, 2020 19:54
Co-Authored-By: Jason Kuhrt <[email protected]>
Co-Authored-By: Jason Kuhrt <[email protected]>
@Weakky Weakky changed the title feat(schema): add schema.middleware helper feat(schema): add schema.middleware Apr 21, 2020
@Weakky Weakky merged commit b1a0377 into master Apr 21, 2020
@Weakky Weakky deleted the feat/schema-middleware branch April 21, 2020 18:41
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