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

Nested field arguments don't seem to be used for conflict validation #108

Open
berstend opened this issue Aug 15, 2019 · 0 comments
Open

Comments

@berstend
Copy link

berstend commented Aug 15, 2019

Hi there,

this might be related to #107 but I figured it would be better to open a new issue as it's related to field arguments.

The following query will raise an error as expected:

{
  country(code: "DE") {
    name
  }
  country(code: "US") {
    name
  }
}

panic: input:6: Fields "country" conflict because they have differing arguments. Use different aliases on the fields to fetch both if this was intentional.

Whereas the same query with nested arguments will not:

{
  countryWhere(where: {code: "DE"}) {
    name
  }
  countryWhere(where: {code: "US"}) {
    name
  }
}

Full test case:

package main

import (
	"fmt"

	"github.com/vektah/gqlparser"
	"github.com/vektah/gqlparser/ast"
)

func main() {
	typedef := `
		type Country {
			name: String
		}

		type Query {
			country(code: String): Country
			countryWhere(where: CountryWhereUniqueInput!): Country
		}

		input CountryWhereUniqueInput {
			code: String
		}
	`
	// query := `
	// 	{
	// 		country(code: "DE") {
	// 			name
	// 		}
	// 		country(code: "US") {
	// 			name
	// 		}
	// 	}
	// `
	query := `
		{
			countryWhere(where: {code: "DE"}) {
				name
			}
			countryWhere(where: {code: "US"}) {
				name
			}
		}
	`

	schema, schemaErr := gqlparser.LoadSchema(&ast.Source{
		Input: typedef,
	})
	if schemaErr != nil {
		panic(schemaErr)
	}

	doc, queryErr := gqlparser.LoadQuery(schema, query)
	if queryErr != nil {
		panic(queryErr)
	}

	fmt.Println(schema, doc)
}

Is this issue of the same origin as #107 or a different beast?

Thanks for the all the great work with gqlparser!

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

1 participant