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

Enhance buildOperationNodeForField by taking default values into consideration #5268

Open
uroslates opened this issue May 11, 2023 · 0 comments · May be fixed by #5269
Open

Enhance buildOperationNodeForField by taking default values into consideration #5268

uroslates opened this issue May 11, 2023 · 0 comments · May be fixed by #5269

Comments

@uroslates
Copy link

First of all - I would like to express my gratitude for the phenomenal work you guys are doing here!


Is your feature request related to a problem? Please describe.

I'm working on an a Project where we're building an SDK generator that parses an OAS based Schemas (with a huge set of endpoints where the parameters have default values specified whenever possible), coverts them into the GraphQL Schema and than builds and exposes the GQL queries/mutations. For exposing the queries we're using the buildOperationNodeForField function.
Unfortunately even though our GQL Schema properly takes and captures default values from the OAS Schema specification, buildOperationNodeForField function ignores them when building queries/mutations, which degrade our DX significantly (for most initial use-cases where we would let our users quickly test generated operations W/O having to provide all argument values for queries/mutations if they have defaults already contained within the GQL Spec).

Describe the solution you'd like

It would be expected that if the GQL Specification Nodes already contains default values (for Queries/Mutations) they would also be taken into consideration and propagated to the output of the buildOperationNodeForField function.

Additional context

It would be expected that the output of the below buildOperationNodeForField fn call:

const document = buildOperationNodeForField({
    schema: buildSchema(/* GraphQL */ `
        type Query {
            getAllPages(currentPage: Int = 0, pageSize: Int = 10, pageType: getAllPages_pageType = ContentPage, sort: String = "asc"): PagesList
        }

        enum getAllPages_pageType {
            ContentPage
            CategoryPage
            CatalogPage
        }

        type PagesList {
            ...
        }
    `),
    kind: 'query' as OperationTypeNode,
    field: 'getAllPages',
    models,
    ignore: [],
  })!;

would match the following:

query getAllPages_query($currentPage: Int = 0, $pageSize: Int = 10, $pageType: getAllPages_pageType = ContentPage, $sort: String = "asc") {
    getAllPages(currentPage: $currentPage, pageSize: $pageSize, pageType: $pageType, sort: $sort) {
        ...
    }
}

I would be more than happy to submit the PR for this feature.

@uroslates uroslates linked a pull request May 11, 2023 that will close this issue
15 tasks
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.

1 participant