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

Add comments type to GraphQL #20

Closed
eshlox opened this issue Nov 30, 2019 · 0 comments
Closed

Add comments type to GraphQL #20

eshlox opened this issue Nov 30, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@eshlox
Copy link
Owner

eshlox commented Nov 30, 2019

The theme allows us to add comments: false to the frontmatter to disable comments for the article.

comments: false

The theme should create a comments type for GraphQL in case there is no article with the comment option, otherwise, it won't work.

I wanted to add this to gatsby-node.js:

exports.createSchemaCustomization = ({ actions, schema }) => {
  const { createTypes, createFieldExtension } = actions;

  createFieldExtension({
    name: `defaultTrue`,
    extend() {
      return {
        resolve(source, args, context, info) {
          if (source[info.fieldName] == null) {
            return true;
          }
          return source[info.fieldName];
        }
      };
    }
  });

  createTypes(`
    type MdxFrontmatter @infer {
      comments: Boolean @defaultTrue
    }
    type Mdx implements Node @infer {
      frontmatter: MdxFrontmatter
    }
  `);
};

but it does not create a new type.

I see these warnings during the build process:

warn Plugin `gatsby-plugin-mdx` tried to define the GraphQL type `MdxFrontmatter`, which has already been defined by the plugin `@eshlox/gatsby-theme-axii`.
warn Plugin `gatsby-plugin-mdx` tried to define the GraphQL type `Mdx`, which has already been defined by the plugin `@eshlox/gatsby-theme-axii`.

Maybe there is another/better way?

@eshlox eshlox added the bug Something isn't working label Nov 30, 2019
@eshlox eshlox closed this as completed in 2ac4589 Dec 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant