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

hasura-allow-list has differing fragment order from apollo-codegen #864

Open
msiegenthaler opened this issue Oct 16, 2024 · 0 comments
Open

Comments

@msiegenthaler
Copy link

msiegenthaler commented Oct 16, 2024

Which packages are impacted by your issue?

@graphql-codegen/hasura-allow-list

Describe the bug

When generating the allow list the order for fragments that depend on each other differs from what the apollo plugin generates. This means that the queries that are send are not in the allow list (hasura compares literal).

I run with globalFragments: true and fragmentsOrder: "document".

Your Example Website or App

msiegenthaler#1

Steps to Reproduce the Bug or Issue

run the newly added test in the PR

Expected behavior

order of fragments respects dependencies between fragements

fragment A {
  ...B
}

must come after fragment B declaration

Screenshots or Videos

No response

Platform

  • OS: macos
  • NodeJS: 22.9.0
  • graphql version: 16.8.1
  • @graphql-codegen/cli: 5.0.0
  • @graphql-codegen/client-preset: 4.1.0
  • HEAD of this repo

Codegen Config File

import {CodegenConfig} from "@graphql-codegen/cli"

const config: CodegenConfig = {
    overwrite: true,
    schema: [
        {
            "http://localhost/v1/graphql": ...    },
        },
    ],
    documents: [
        "src/**/*.ts",
        "src/**/*.tsx",
    ],
    generates: {
        "src/gql/": {
            preset: "client",
            presetConfig: {
                fragmentMasking: false,
            },
            config: {
                avoidOptionals: {
                    field: true,
                    object: true,
                    defaultValue: false,
                    input: false,
                },
                immutableTypes: true,
            },
        },
        "allow_list.yaml": {
            plugins: ["hasura-allow-list"],
            config: {
                globalFragments: true,
                fragmentsOrder: "document",
            },
        },
    },
}

export default config

Additional context

No response

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

No branches or pull requests

1 participant