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

Introspection schema returns empty values for input types #4

Closed
danielvladco opened this issue Jul 15, 2019 · 12 comments
Closed

Introspection schema returns empty values for input types #4

danielvladco opened this issue Jul 15, 2019 · 12 comments

Comments

@danielvladco
Copy link
Contributor

main.go:

schemas, err := graphql.IntrospectRemoteSchemas(
		"http://localhost:3004/query",
		"http://localhost:3002/query",
		"http://localhost:3006/query",
	)
	if err != nil {
		panic(err)
	}

	// create the gateway instance
	gw, err := gateway.New(schemas)
	if err != nil {
		panic(err)
	}
	http.HandleFunc("/graphql", gw.PlaygroundHandler)

gql schema:

# ... Service A
input ChangeCompanyInfoReqInput {
	company: CompanyInput  
}

# ... Service B
input DeleteSkillReqInput {
	id: String  
}

# ...

gql query:
"Introspection Query"

expected result:
The complete json representation of gql scheam

got:

"types": [
        {
          "description": "",
          "enumValues": [],
          "fields": [],
          "inputFields": [],
          "interfaces": [],
          "kind": "",
          "name": "ChangeCompanyInfoReqInput",
          "possibleTypes": []
        },
        {
          "description": "",
          "enumValues": [],
          "fields": [],
          "inputFields": [],
          "interfaces": [],
          "kind": "",
          "name": "DeleteSkillReqInput",
          "possibleTypes": []
        },
]

all Input types are like this.

@AlecAivazis
Copy link
Member

AlecAivazis commented Jul 15, 2019

Hey @danielvladco! Thanks for opening this. I think this issue belongs in the nautilus/graphql package. I'll move it over there for you.

I have some time to investigate this today so hopefully I'll have something for you soon

@AlecAivazis AlecAivazis transferred this issue from nautilus/gateway Jul 15, 2019
@AlecAivazis
Copy link
Member

Okay so I've tried to see if I can reproduce your problem and I think I need a bit more information.

I ran the following code in a script and was able to find the fields for an input type:

// introspect the apis
schemas, err := graphql.IntrospectRemoteSchemas(
	"https://api.graphql.jobs/",
)
if err != nil {
	panic(err)
}

fmt.Println(schemas[0].Schema.Types["TagWhereInput"].Fields)

Is the payload you posted above a response from introspecting the gateway? Or is that the introspection query to one of the backend services?

@danielvladco
Copy link
Contributor Author

Hi @AlecAivazis ,
Thanks for quick reply,

run this piece of code:

schemas, err := graphql.IntrospectRemoteSchemas(
	"https://api.graphql.jobs/",
)
if err != nil {
	panic(err)
}

, _ := json.Marshal(schemas[0].Schema.Types["TagWhereInput"])
fmt.Printf("%s/n", string(b))

notice how Kind field for input type is empty, when it's expected to be INPUT_OBJECT
also there are Fields but for some reason all their fields are resolved to zero values except for field Name and Type

You can introspect the endpoint directly and see all the mismatching fields.

@AlecAivazis
Copy link
Member

Ah yea I noticed a similar inconsistency today while digging through this. I'll try to have a fix for you very soon. Sorry about this!

@AlecAivazis
Copy link
Member

AlecAivazis commented Jul 16, 2019

Okay i just pushed a fix that assigns the right Kind to input objects. I tested the script again and am able to interact with the API through the playground provided by the gateway.

Looking at the introspection query used in the gateway (the same used by most libraries) we only ask for name, description, defaultValue, and type information on input objects. Is something missing that you usually see with other introspections?

@AlecAivazis
Copy link
Member

@danielvladco are you still seeing issues?

@danielvladco
Copy link
Contributor Author

danielvladco commented Jul 18, 2019

@AlecAivazis Unfortunately yes,

I use Insomnia as my graphql client and when it's trying to do introspection query I receive this error:
image

however when I use direct link It works fine

@AlecAivazis
Copy link
Member

Okay that’s progress! Looks like insomnia is expecting a directive to be defined that isn’t. I’ll go download it and give it a try

@AlecAivazis
Copy link
Member

Alright I think we're in business now. I was able to reproduce your issue in insomnia. There was an error when pulling in the locations for directives. It should be fixed now in v0.0.8. Sorry for the inconvenience!

@danielvladco
Copy link
Contributor Author

Thanks, It seems to work now

You forgot a print here https://github.com/nautilus/graphql/blob/master/introspection.go#L196
:)

@AlecAivazis
Copy link
Member

AlecAivazis commented Jul 19, 2019

Whoops! Thanks for catching that. It should be gone now 😄

@sbilello
Copy link

sbilello commented Apr 5, 2021

@danielvladco @AlecAivazis
In a real production ready example, there is no schema registry involved with nautilus?
"http://localhost:3004/query",
"http://localhost:3002/query",
"http://localhost:3006/query",
How do you dynamically update the service list?

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

3 participants