Skip to content

Add additionalTypes to generateSchema #622

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

Merged
merged 5 commits into from
Feb 27, 2020
Merged

Conversation

de55
Copy link
Contributor

@de55 de55 commented Feb 27, 2020

📝 Description

Additional types cannot be edited, but comments suggest that is the appropriate way to add additional types before generateAdditionalTypes() is called:

    /**
     * Generate the GraphQL type for all the `additionalTypes`. They are generated as non-inputs and not as IDs.
     * If you need to provide more custom additional types that were not picked up from reflection of the schema objects,
     * you can modify the set of `additionalTypes` before you call this method.
     *
     * This function is recursive because while generating the additionalTypes it is possible to create additional types that need to be processed.
     */

🔗 Related Issues

#615

@de55 de55 changed the title Make SchemaGenerator.additionalTypes public Make SchemaGenerator additionalTypes public Feb 27, 2020
@smyrick
Copy link
Contributor

smyrick commented Feb 27, 2020

@de55 I was just looking at this last night and realized our mistake. Thank you for all being on top of changes as an active community member.

How about instead of changing the scope of additionalTypes we add a new optional argument to generateSchema that will allow you to add these.

open fun generateSchema(
        queries: List<TopLevelObject>,
        mutations: List<TopLevelObject> = emptyList(),
        subscriptions: List<TopLevelObject> = emptyList(),
        additionalTypes: Set<KType> = emptySet()
): GraphQLSchema {

    this.additionalTypes.addAll(additionalTypes)
    val builder = GraphQLSchema.newSchema()
    // ... rest of code
}

Then we can make generateAdditionalTypes just protected and not protected open.

@smyrick
Copy link
Contributor

smyrick commented Feb 27, 2020

If you update the scope of generateAdditionalTypes can you also change the javadocs to the following:

    /**
     * Generate the GraphQL type for all the `additionalTypes`. They are generated as non-inputs and not as IDs.
     * If you need to provide more custom additional types that were not picked up from reflection of the schema objects,
     * you can provide more types to be added through [generateSchema].
     *
     * This function loops because while generating the additionalTypes it is possible to create more additional types that need to be processed.
     */

@de55 de55 changed the title Make SchemaGenerator additionalTypes public Add additionalTypes to generateSchema Feb 27, 2020
@smyrick smyrick added the changes: major Changes require a major version label Feb 27, 2020
@smyrick
Copy link
Contributor

smyrick commented Feb 27, 2020

This is a major change on the master branch since we removed the open modified on generateAdditionalTypes but that was only added in on the 2.0 branch so we are back to being backwards compatible with 1.x for this method call at least

@smyrick smyrick merged commit b129244 into ExpediaGroup:master Feb 27, 2020
dariuszkuc pushed a commit to dariuszkuc/graphql-kotlin that referenced this pull request Aug 5, 2022
* Make additionalType public

* fix linting issue

* Update SchemaGenerator.kt

* Switch additionalTypes back to internal

* fix federated schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes: major Changes require a major version
Development

Successfully merging this pull request may close these issues.

2 participants