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

Operations plugin generates a single item for array types #27

Closed
ertrzyiks opened this issue Mar 26, 2022 · 1 comment · Fixed by #29
Closed

Operations plugin generates a single item for array types #27

ertrzyiks opened this issue Mar 26, 2022 · 1 comment · Fixed by #29

Comments

@ertrzyiks
Copy link
Contributor

ertrzyiks commented Mar 26, 2022

Using the config like

./src/:
    preset: near-operation-file
    presetConfig:
      extension: .generated.ts
      baseTypesPath: types.ts
    plugins:
      - typescript-operations
      - graphql-codegen-factories/operations

When a selection references an array, the factory returns a single element.

When the

query { 
  allStrapiRecipe {
    edges { # this is an array
      node {
        ...fields
      }
    }
  }
}

Expected

{
  allStrapiRecipe: {
    __typename: 'StrapiRecipeConnection',
    edges: [{
      __typename: 'StrapiRecipeEdge',
      node: {
        __typename: 'StrapiRecipe',
      },
    }]
  },
}  

Actual

{
  allStrapiRecipe: {
    __typename: 'StrapiRecipeConnection',
    edges: {
      __typename: 'StrapiRecipeEdge',
      node: {
        __typename: 'StrapiRecipe',
      },
    },
  }
}  

Tested with yummy-recipes/yummy#58

@zhouzi
Copy link
Owner

zhouzi commented Mar 27, 2022

Thanks for the report, it's fixed in graphql-codegen-factories@1.0.0-beta.2

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 a pull request may close this issue.

2 participants