You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following up on the great work by @shoma-mano. There seems to be an issue with the fragment order in the generated allow lists when using fragmentOrder set to document and there are nested fragments spread across several files, compared to the order generated by typed-document-node.
Allow lists and document are generated in folder named generated
Confirm that BookData comes before AuthorData in GetBook query in allow list
- name: allowed-queriesdefinition:
queries:
- name: GetBookquery: |- query GetBook { book { ...BookData } } fragment BookData on Book { name author { ...AuthorData } } fragment AuthorData on Author { name }
Confirm that AuthorData appear before BookData in GetBookDocument generated by typed-document-node (generated/graphql.ts)
export const AuthorDataFragmentDoc = {...} as unknown as DocumentNode<AuthorDataFragment, unknown>;
export const BookDataFragmentDoc = {...} as unknown as DocumentNode<BookDataFragment, unknown>;
export const GetBookDocument = {...} as unknown as DocumentNode<GetBookQuery, GetBookQueryVariables>;
Run pnpm test and confirm that the query generated by print from the graphql package generates the following query:
query GetBook {
book {
...BookData
}
}
fragment AuthorData on Author {
name
}
fragment BookData on Book {
name
author {
...AuthorData
}
}
Which packages are impacted by your issue?
@graphql-codegen/hasura-allow-list
Describe the bug
Following up on the great work by @shoma-mano. There seems to be an issue with the fragment order in the generated allow lists when using
fragmentOrder
set todocument
and there are nested fragments spread across several files, compared to the order generated bytyped-document-node
.Your Example Website or App
https://github.com/voldern/hasura-allowlist-reproduction
Steps to Reproduce the Bug or Issue
pnpm codegen
/ graphql-codegengenerated
generated/graphql.ts
)pnpm test
and confirm that the query generated byprint
from thegraphql
package generates the following query:Expected behavior
Compatible with other plugins.
Screenshots or Videos
No response
Platform
graphql
version: [16.9.0]@graphql-codegen/
version(s):"@graphql-codegen/typed-document-node": "^5.0.9",
"@graphql-codegen/typescript": "^4.0.9",
"@graphql-codegen/typescript-graphql-request": "^6.2.0",
"@graphql-codegen/typescript-operations": "^4.2.3",
Codegen Config File
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: [
{
"./schema.graphql": {
assumeValid: true,
},
},
],
documents: ["./queries/*.ts"],
generates: {
"./generated/query_collections.yaml": {
plugins: ["hasura-allow-list"],
config: {
globalFragments: true,
fragmentsOrder: "document",
},
},
"./generated/": {
preset: "client",
presetConfig: {
gqlTagName: "gql",
},
},
},
};
export default config;
Additional context
No response
The text was updated successfully, but these errors were encountered: