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

Nested private types are shown in the examples #1417

Closed
Dodoboulistick opened this issue Apr 15, 2024 · 3 comments · Fixed by #1419 or #1422
Closed

Nested private types are shown in the examples #1417

Dodoboulistick opened this issue Apr 15, 2024 · 3 comments · Fixed by #1419 or #1422
Assignees
Labels
bug Something isn't working

Comments

@Dodoboulistick
Copy link

Dodoboulistick commented Apr 15, 2024

Describe the bug
In the objects (at least) : I can't ignore custom directives in examples when some types are nested. It doesn't show in the first type codeblock (as expected) but it does show in the example (unexpected).

To Reproduce
Create the simple schema below, and run docusaurus graphql-to-doc && docusaurus build . You can go on the given object in the sidebar (e.g. Cat) and see the type/example.

  • GraphQL schema
directive @example(
  value: String
) on OBJECT | INPUT_OBJECT | INTERFACE | FIELD_DEFINITION | ARGUMENT_DEFINITION | SCALAR | INPUT_FIELD_DEFINITION | ENUM

directive @private on OBJECT | INPUT_OBJECT | INTERFACE | FIELD_DEFINITION | ARGUMENT_DEFINITION | SCALAR | INPUT_FIELD_DEFINITION | ENUM

type Cat {
  id: ID! @example(value: "123")
  name: String! @example(value: "Kitty")
  age: Int! @example(value: "3")
  owner: Person! @private
}

type Dog {
  id: ID! @example(value: "123")
  name: String! @example(value: "Rex")
  age: Int! @example(value: "5")
  owner: Person! @private
}

type Person {
  id: ID! @example(value: "123")
  name: String! @example(value: "John")
  age: Int! @example(value: "30")
  bankAccount: String! @private
}
  • Docusaurus configuration
export default async function createConfig() {
  return {
    ...notInterestingStuff,
presets: [
      [
        'classic',
        {
          docs: {
            routeBasePath: '/',
            sidebarPath: './sidebars.ts',
            // docRootComponent: '@theme/DocPage',
            docItemComponent: '@theme/ApiItem', // add @theme/ApiItem here
            async sidebarItemsGenerator({
              defaultSidebarItemsGenerator,
              ...args
            }) {
              const sidebarItems = await defaultSidebarItemsGenerator(args);

              return ignoreCommonFolder(sidebarItems);
            },
          },
          blog: false,
          // blog: {
          //   showReadingTime: true,
          // },
          theme: {
            customCss: './src/css/custom.css',
          },
        } satisfies Options,
      ],
    ],
plugins: [
      [
        '@graphql-markdown/docusaurus',
        {
          schema: 'specs/schema.graphql',
          baseURL: './APIs/database',
          loaders: loaderList,
          printTypeOptions: {
            deprecated: 'group',
            parentTypePrefix: false,
            useApiGroup: false,
            typeBadges: false,
            exampleSection: {
              directive: 'example',
            },
          },
          docOptions: {
            frontMatter: {
              hide_table_of_contents: true,
              pagination_next: null,
              pagination_prev: null,
            },
          },
          skipDocDirective: ['@private' as DirectiveName],
        } satisfies ConfigOptions,
      ],
    ],

Expected behavior
In the example I just gave (+ screenshots) we can see that even though the Person attribute doesn't show in the initial type definition, it does show in the example.
However, if the type isn't nested (that's the case for bankAccount, it works as expected as we don't see it in the example.

Screenshots
image

In any case, thank you very much for your plugin, which is really cool and saves a lot of time!

@Dodoboulistick Dodoboulistick added the bug Something isn't working label Apr 15, 2024
@edno
Copy link
Member

edno commented Apr 15, 2024

Hi @Dodoboulistick
Good catch! The example feature is missing the support for non-printable type.
A fix will be released this week.

@edno edno reopened this Apr 16, 2024
@edno edno linked a pull request Apr 19, 2024 that will close this issue
5 tasks
@edno
Copy link
Member

edno commented Apr 19, 2024

Fix published in release 1.24.1 🚀

@Dodoboulistick
Copy link
Author

@edno many thanks for your reactivity!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants