Skip to content

Support extending interfaces #147

Open

Description

@sebastiandev

Reporting issues with GraphQL-core 3

The GraphQL protocol already supports interfaces extending other interfaces like

interface Identifiable {
  id: ID!
}

interface Resource implements Identifiable {
  id: ID!
  name: String!
}

type SomeResource implements Resource {
  id: ID!
  name: String!
}

When loading the schema we get an error

File "/usr/local/lib/python3.6/site-packages/graphql/type/validate.py", line 91, in assert_valid_schema
   raise TypeError("\n\n".join(error.message for error in errors))
   TypeError: Type SomeResource must implement Identifiable because it is implemented by Resource.

This can be solved by doing

type SomeResource implements Resource & Identifiable {
  id: ID!
  name: String
}

But its a bit annoying

Activity

  1. self-assigned this
    on Nov 22, 2021
  2. Cito commented on Nov 22, 2021

    @Cito
    Member

    Hi @sebastiandev. Your example should actually work. Which version of GraphQL-core are you using and can you post the exact code that produces this error?

  3. Cito commented on Nov 22, 2021

    @Cito
    Member

    Just noticed this was implemented in v3.1 only. Maybe you're still on v3.0?

  4. sebastiandev commented on Nov 22, 2021

    @sebastiandev
    Author

    I'm on 3.1.6 using Ariadne. Looks like it supports an interface implementing another, but then it shows that error message

    interface Node {
      id: String!
    }
    
    type PageInfo {
      hasNextPage: Boolean!
      hasPreviousPage: Boolean!
      startCursor: String
      endCursor: String
    }
    
    interface Identifiable implements Node {
        id: String!
        legacy_id: Int
    }
    
    type AccountEdge {
      cursor: String!
      node: Account
    }
    
    type AccountConnection {
      pageInfo: PageInfo!
      edges: [AccountEdge]
    }
    
    type Account implements Identifiable {
      id: String!
      legacy_id: Int
      email: String
      customers: AccountConnection
    }
  5. Cito commented on Nov 23, 2021

    @Cito
    Member

    Hm, I still can't reproduce it with 3.1. Can you double-check the version with print(graphql.version_info) and post some Python code (not just SDL) that creates the error message above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions