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

Building schema failed: Type <type name> declared in createTypes looks like a node, but doesn't implement a Node interface #136

Closed
arsinclair opened this issue Jul 22, 2021 · 10 comments

Comments

@arsinclair
Copy link

arsinclair commented Jul 22, 2021

Description

With @imgix/gatsby enabled, gatsby develop and gatsby build result in the following error:

warn Type ImagesJson declared in createTypes looks like a node, but doesn't implement a Node interface. It's likely that you should add the Node interface to your type def:
type ImagesJson implements Node { ... }
If you know that you don't want it to be a node (which would mean no root queries to retrieve it), you can explicitly disable inference for it:
type ImagesJson @dontInfer { ... }
ERROR
Building schema failed
not finished building schema - 0.106s

To Reproduce
I have the following tandem configured: gatsby-source-filesystem to read a json file called images.json with data, like this:

[
    {
        "url": "https://bucket.imgix.net/images/header/splash.jpg"
    }
]

then gatsby-transformer-json to parse the JSON file, and finally @imgix/gatsby with the following configuration:

        {
            resolve: "@imgix/gatsby",
            options: {
                domain: "bucket.imgix.net",
                sourceType: ImgixSourceType.AmazonS3,
                fields: [
                    {
                        nodeType: "ImagesJson",
                        getURL: (node) => node.url,
                        fieldName: 'image'
                    }
                ]
            }
        }

If I disable @imgix/gatsby in the config - build succeeds. The JSON is parsed just fine, verified in GraphiQL.

It appears to be clear that the issue is isolated to imgix/gatsby.

Expected behaviour
No error, and an images node with stuff added to my ImagesJson object. The configuration above used to work with gatsby-plugin-imgix and Gatsby v2 before.

Information:

  • imgix/gatsby version: 1.6.11
  • browser version: Version 1.25.72 Chromium: 91.0.4472.101 (Official Build) (64-bit)
  • OS used: Debian GNU/Linux 10 (buster)

Additional context
I'm happy to provide any additional information, if required.

@frederickfogerty
Copy link
Contributor

frederickfogerty commented Jul 23, 2021

Hi @arsinclair 👋 thanks for opening this issue. Sorry that you've had this experience - I've put this on my schedule to investigate next week. I'll provide any updates here.

@arsinclair
Copy link
Author

Hi @cecasey wave thanks for opening this issue.

Pardon? 🙁

@frederickfogerty
Copy link
Contributor

frederickfogerty commented Jul 26, 2021

Sorry @arsinclair, I was responding to another issue at the same time and I must have got my wires crossed here!

@luqven
Copy link
Contributor

luqven commented Aug 3, 2021

Hey @arsinclair,

Having trouble reproducing the issue. Do you think you could create and link an example repo that reproduces it?

Thanks again for taking the time to report this.

@arsinclair
Copy link
Author

Do you think you could create and link an example repo that reproduces it

Sure. Here's the repo: https://github.com/arsinclair/gatsby-image-schema-bug-reproduction

Just run npm install && npm run develop.

P.S.: I used a test image from imgix, because I can not use put my organization's endpoint. I don't know if Imgix uses Amazon.S3 as the backend for their assets.imgix.net, but it is clear that the issue is reproduced with any image.

@arsinclair
Copy link
Author

arsinclair commented Aug 4, 2021

If you comment out the @imgix/gatsby config in gatsby-config.js file and use GraphiQL, you'll see that the actual image URL is parsed okay and the type name matches:

{
  imagesJson {
  	__typename
    url
  }
}

output:

{
  "data": {
    "imagesJson": {
      "__typename": "ImagesJson",
      "url": "https://assets.imgix.net/examples/bluehat.jpg"
    }
  },
  "extensions": {}
}

luqven added a commit that referenced this issue Aug 4, 2021
This commit addresses issue #136. When extending nodes that were defined
with Node inference, the plugin can at times fail to detect the Node
interface. For example, if the original node being extented was defined
using SDL, extending it without adding `interfaces: Node` will mean that
GraphQl doesn't know that the node being created extends the Node type.
This mean that our plugin could cause errors to be thrown at build time,
as the newly created type was expected to be a Node type but was not.
For more information see the Gatsby documentation here:
https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#gatsby-type-builders

It says, "When defnining top level types, don't forget to pass
`interfaces: ['Node']`, which does the same for Type Builders as adding
`implements Node` to SDL-defined types."
luqven added a commit that referenced this issue Aug 5, 2021
This commit addresses issue #136. When extending nodes that were defined
with Node inference, the plugin can at times fail to detect the Node
interface. For example, if the original node being extented was defined
using SDL, extending it without adding `interfaces: Node` will mean that
GraphQl doesn't know that the node being created extends the Node type.
This mean that our plugin could cause errors to be thrown at build time,
as the newly created type was expected to be a Node type but was not.
For more information see the Gatsby documentation here:
https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#gatsby-type-builders

It says, "When defnining top level types, don't forget to pass
`interfaces: ['Node']`, which does the same for Type Builders as adding
`implements Node` to SDL-defined types."
imgix-git-robot pushed a commit that referenced this issue Aug 5, 2021
### [1.6.12-rc.1](v1.6.11...v1.6.12-rc.1) (2021-08-05)

### Bug Fixes

* **pe1168:** looks like node but missing interface ([bbee4e4](bbee4e4)), closes [#136](#136)

 [skip ci]
@luqven
Copy link
Contributor

luqven commented Aug 5, 2021

Hey @arsinclair,

Thanks again for sending over the example repo, it was extremely helpful!

This issue should be fixed in version 1.6.12-rc.1. You can install it by running npm i @imgix/gatsby@next or npm i @imgix/gatsby@1.6.12-rc.1.

If for any reason this isn't resolved please free to comment on this issue so we can open it up again.

@luqven luqven closed this as completed Aug 5, 2021
@lezan
Copy link

lezan commented Nov 16, 2021

Hey @luqven, can you confirm this is fixed with 1.7.1 and there is not a regression? I am experience the same issue of @arsinclair but with ImgixSourceType.WebProxy.

luqven added a commit that referenced this issue Dec 8, 2021
This commit addresses issue #136. When extending nodes that were defined
with Node inference, the plugin can at times fail to detect the Node
interface. For example, if the original node being extented was defined
using SDL, extending it without adding `interfaces: Node` will mean that
GraphQl doesn't know that the node being created extends the Node type.
This mean that our plugin could cause errors to be thrown at build time,
as the newly created type was expected to be a Node type but was not.
For more information see the Gatsby documentation here:
https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#gatsby-type-builders

It says, "When defnining top level types, don't forget to pass
`interfaces: ['Node']`, which does the same for Type Builders as adding
`implements Node` to SDL-defined types."
@luqven
Copy link
Contributor

luqven commented Dec 8, 2021

@lezan thanks for tagging me and letting me know this issue wasn't fixed.

It appears that #138 never made it into main. I've gone ahead and PRd #154 the change and will update when it's released.

@luqven luqven reopened this Dec 8, 2021
luqven added a commit that referenced this issue Dec 8, 2021
This commit addresses issue #136. When extending nodes that were defined
with Node inference, the plugin can at times fail to detect the Node
interface. For example, if the original node being extented was defined
using SDL, extending it without adding `interfaces: Node` will mean that
GraphQl doesn't know that the node being created extends the Node type.
This mean that our plugin could cause errors to be thrown at build time,
as the newly created type was expected to be a Node type but was not.
For more information see the Gatsby documentation here:
https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/#gatsby-type-builders

It says, "When defnining top level types, don't forget to pass
`interfaces: ['Node']`, which does the same for Type Builders as adding
`implements Node` to SDL-defined types."
imgix-git-robot pushed a commit that referenced this issue Dec 8, 2021
### [1.7.3](v1.7.2...v1.7.3) (2021-12-08)

### Bug Fixes

* **pe1168:** looks like node but missing interface ([9c25082](9c25082)), closes [#136](#136)

 [skip ci]
@luqven
Copy link
Contributor

luqven commented Dec 8, 2021

Hey @lezan, thanks again for letting us know this was still an issue.

The issue should be fixed in version 1.7.3. You can install it by running npm i @imgix/gatsby@latest or npm i @imgix/gatsby@1.7.3.

If for any reason this isn't resolved please free to comment on this issue so we can open it up again.

@luqven luqven closed this as completed Dec 8, 2021
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

No branches or pull requests

4 participants