dotansimha / dotansimha/graphql-code-generator-community

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

Open
#864 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

### 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

https://github.com/msiegenthaler/graphql-code-generator-community/pull/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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.