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 Support for Interfaces Implementing Interfaces #416

Closed
lukephillippi opened this issue Nov 8, 2020 · 1 comment
Closed

Add Support for Interfaces Implementing Interfaces #416

lukephillippi opened this issue Nov 8, 2020 · 1 comment

Comments

@lukephillippi
Copy link

lukephillippi commented Nov 8, 2020

Expected Behavior

As implemented via graphql/graphql-spec#373, the GraphQL draft specification now indicates that schema definitions can include interfaces that implement other interfaces. As an example, the following should be considered valid schema definition syntax and thus be parsed successfully by the ParseSchema and MustParseSchema functions:

interface Node {
  id: ID!
}

interface Resource implements Node {
  id: ID!
  url: String
}

Actual Behavior

However, it appears that this syntax is not yet supported with the current version of the graph-gophers/graphql-go package (v0.0.0-20201027172035-4c772c181653).

Attempting to parse a schema definition using this new syntax results in an error:

...
panic: graphql: syntax error: unexpected "implements", expecting "{" (line 10, column 20)
...

Reproduction Code (Go Playground)

package main

import "github.com/graph-gophers/graphql-go"

const schema = `
type Query {
  node: Node!
}

interface Node {
  id: ID!
}

interface Resource implements Node {
  id: ID!
  url: String
}
`

type resolver struct{}

func (_ *resolver) Node() *node {
	return &node{}
}

type node struct{}

func (_ *node) ID() graphql.ID {
	return graphql.ID("foo")
}

func (n *node) ToResource() (*resource, bool) {
	return &resource{n}, true
}

type resource struct {
	*node
}

func (_ *resource) URL() *string {
	u := "https://github.com/graph-gophers/graphql-go"
	return &u
}

func main() {
	graphql.MustParseSchema(schema, &resolver{})
}

Any chance that y'all could add support for the interfaces implementing interfaces syntax?

Thank you in advance and for the great framework!

@lukephillippi lukephillippi changed the title Interfaces Implementing Interfaces Add Support for Interfaces Implementing Interfaces Nov 13, 2020
@pavelnikolov
Copy link
Member

Closing this issue as it has been resolved by #471

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

No branches or pull requests

2 participants