-
Notifications
You must be signed in to change notification settings - Fork 8
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: @amplienceContentType fieldOrder #101
base: main
Are you sure you want to change the base?
feat: @amplienceContentType fieldOrder #101
Conversation
67d2a3f
to
b081534
Compare
Can you run |
The current behavior is to keep the GraphQL definition order. Can you tell me why this isn't sufficient? What problem is this PR trying to solve? |
Current behavior is actually to output fields in alphabetical order (see content-type.json). This results in some pretty counterintuitive content forms for our editors, so we wanted control over the output to improve that experience. I was hoping for an automatic solution to respect definition order, but found that:
This explicit argument felt a good compromise. |
Have you tried to disable sorting in the codegen file? Do you run into any other problems with that? import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
overwrite: true,
config: {
sort: false,
},
generates: {
... |
...I did try that as a first attempt during investigation well before looking at a plugin solution, and found it didn't appear to work for whatever reason. Trying it now...it does. Suffice it to say I'm more than puzzled. Where does that leave us with this feature? Reckon it's worth keeping for any potential use case, or dropping outright? |
I think it's because somehow the sort only works in the root config, and not in a config scoped within a generate. I'll keep this PR open for a couple of weeks to be sure. |
710e181
to
6ccbaab
Compare
New optional
fieldOrder
argument for@amplienceContentType
. Allows the developer to explicitly control thepropertyOrder
in a given content type's JSON output.Example:
The following schema:
Outputs:
Validation
Must not specify fields with
@amplienceDeliveryKey
or@amplienceIgnore
(These are handled uniquely with regards to JSON output, so do not need specifying)
Must specify all extant non-illegal fields
Must not specify unknown field names