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

Support extending interfaces #147

Open
sebastiandev opened this issue Nov 22, 2021 · 4 comments
Open

Support extending interfaces #147

sebastiandev opened this issue Nov 22, 2021 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@sebastiandev
Copy link

sebastiandev commented Nov 22, 2021

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

@Cito Cito self-assigned this Nov 22, 2021
@Cito
Copy link
Member

Cito commented Nov 22, 2021

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?

@Cito Cito added the question Further information is requested label Nov 22, 2021
@Cito
Copy link
Member

Cito commented Nov 22, 2021

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

@sebastiandev
Copy link
Author

sebastiandev commented Nov 22, 2021

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
}

@Cito
Copy link
Member

Cito commented Nov 23, 2021

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
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants