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: partial schema update #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

mkmarek
Copy link
Collaborator

@mkmarek mkmarek commented Nov 11, 2022

No description provided.

graphqlUtils.go Outdated Show resolved Hide resolved
Comment on lines 34 to 43
combined, err := combineSchemas(`
type Query {
}`, `
type Query {
hello: String
}`, []Resolver{})

assert.Nil(t, err)
assertEqualNoWhitespace(t, `type Query {}`, combined)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This will create a mismatch between a local GraphQL schema and remote GraphQL schema

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it will, in the same way as there's gonna be a mismatch between local function code and remote deployed function code.

Copy link
Contributor

Choose a reason for hiding this comment

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

But I think this resource/action should be separated from the structure of the consuming project ie.ch-api.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The structure is already dictated by resolvers_file. It is completely OK to invoke this action with different resolver files to achieve partial updates. This just ensures that when you do partial updates the schema will be consistent with the resolvers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to clear my point a bit more regarding the schema mismatch in the next comment 👇

@mhd999
Copy link
Contributor

mhd999 commented Nov 11, 2022

I think this option should be named differently Because the resource/action can be used to either update Schema or resolvers or both when enabling this partial update a resolver file should be opted-in and I think this require more documentation to be understood.

@mkmarek
Copy link
Collaborator Author

mkmarek commented Nov 11, 2022

I could do this:

  • resolved_fields_only: Optional. If true while updating the AppSync schema from schema_file only the fields and their types defined in the resolvers_file will be updated. This will work recursively for all nested types. Default: false. If resolved_types_only is true then schema_file and resolvers_file are Required.

@mhd999
Copy link
Contributor

mhd999 commented Nov 11, 2022

Or maybe resolvers_file_strict? the reason is (referring to the previous comment) if the schema file contains unresolved fields by the resolvers_file then maybe the action/resource should yield that in the console as info?.

Example case:

DevOps eng: created CI pipeline with appsync-resource, resolvers_file_strict = true

Dev: wanted to create a field that resolves to data-source like DynamoDB or any other data-source however this dev wants to create the resolver manually as he/she thinks/wants to use the appsync-resource to update the schema only in this case am wondering if it should be communicated in both docs/README and action/resource logs when the job is done.

example message maybe:

Field Foo is not added to the schema becuase there is no field resolver exist in the resolvers_file

@mkmarek
Copy link
Collaborator Author

mkmarek commented Nov 11, 2022

Logging it is definitely a good idea. it will complicate it a bit because I'm gonna have to make a full diff of the two schemas and pick only the nodes (and their descendants) that get affected by the resolvers. I'll look into it.

The primary use case here is for a case where you don't want to deploy every single resolver in your solution. There are various reasons why you wouldn't want to do that. Our reason is separate AWS lambda versioning. But it could be that you're making a larger change that changes several resources (Like changing dynamodb tables) and you want to ship it incrementally resolver by resolver.

There shouldn't really be breaking changes in the schema either way, so in the ideal case, this change is not necessary because you already can ship different resolvers independently. But this ideal case doesn't always hold.

Either way. I'll look how I can make it more expressive.

@mhd999
Copy link
Contributor

mhd999 commented Nov 11, 2022

I think a message says that some fields are not added to the deployed schema because resolved_fields_only is enabled and no resolver resolve to the them in supplied resolver file is also sufficient

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