Central repo for various odds and ends
nautilus / graphql Goto Github PK
View Code? Open in Web Editor NEWA package with convenience methods for building graphql tooling on the server
License: MIT License
A package with convenience methods for building graphql tooling on the server
License: MIT License
Some GraphQL Schema needs to be authenticated before they can be accessed, but currently, the IntrospectAPI does not support authentication feature support. Generally, the authentication function of GraphQL is implemented through HTTP Header, and the function support can be provided by exposing parameters.
The operationName should be IntrospectionQuery
which causing Unknown operation name
when query IntrospectionQuery
..\github.com\carted\graphql\language\printer\printer.go:372:9: undefined: ast.NullValue
Currently the printer converts the query to a document from graphql-go/graphql
and uses their printer
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.
Scenario:
We have multiple remote APIs which serve our graphql server for response.
We're facing intermittent issue for APIs while using IntrospectAPI() where our APIs are in working/serving state but IntrospectAPI() return 404 API not found/ Network error.Do we have any param which can be used to retry establishing connection with IntrospectAPI().
Any other solution to handle the issue is also appreciated
I have a case which requires setting certain headers for the initial IntrospectRemoteSchemas
call.
Presently, I do not see a built in way to provide this and I am seeking feedback on:
If an addition is required perhaps one approach could including new-ing up an introspection request object of some sort and then calling WithMiddlewares(...)
Currently receive this error: Fragment cannot be spread here as objects of type "Node" can never be of type "Foo"
When running this query:
query {
node(id: "resource") {
... on Resource {
id
}
}
}
Against this schema:
{
"__schema": {
"queryType": {
"name": "Query"
},
"types": [
{
"description": null,
"enumValues": [],
"fields": [
{
"args": [
{
"defaultValue": null,
"description": null,
"name": "id",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
],
"deprecationReason": null,
"description": "Find a Node for the given ID. Use fragments to select additional fields.",
"isDeprecated": false,
"name": "node",
"type": {
"kind": "INTERFACE",
"name": "Node",
"ofType": null
}
}
],
"inputFields": [],
"interfaces": [],
"kind": "OBJECT",
"name": "Query",
"possibleTypes": []
},
{
"description": "A resource.",
"enumValues": [],
"fields": [
{
"args": [],
"deprecationReason": null,
"description": "The ID of this resource.",
"isDeprecated": false,
"name": "id",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
],
"inputFields": [],
"interfaces": [
{
"kind": "INTERFACE",
"name": "Node",
"ofType": null
}
],
"kind": "OBJECT",
"name": "Resource",
"possibleTypes": []
},
{
"description": "Fetches an object given its ID.",
"enumValues": [],
"fields": [
{
"args": [],
"deprecationReason": null,
"description": "The globally unique object ID.",
"isDeprecated": false,
"name": "id",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
],
"inputFields": [],
"interfaces": [],
"kind": "INTERFACE",
"name": "Node",
"possibleTypes": [
{
"kind": "INTERFACE",
"name": "Node",
"ofType": null
},
{
"kind": "OBJECT",
"name": "Resource",
"ofType": null
}
]
}
]
}
}
Hello!
It seems like there is an issue with the deprecated fields.
I am specifying a list of URLs and using graphql.IntrospectRemoteSchemas(...)
to get my schema.
I realised that the behaviour of resolving deprecated
fields is invalid.
My schema:
"Description"
property_a: [TypeA!] @deprecated(reason: "In favor of ...")
Expected result:
# Deprecated: In favor of ...
property_a: [TypeA!]
Actual result:
"Description"
property_a: [TypeA!]
Hello! We tried to update to version 0.0.17 version of this package and started getting following errors on handling our queries (I assume actually parsing the query itself). All errors are referring union types:
Fragment cannot be spread here as objects of type \"<some union type>\" can never be of type \"< part of that union >\".
Basically, any union spread in the query causes this error.
We solved by rolling back to 0.0.16 thanks if you will have time to look into it!
Hi,
I am using the nautilus gateway
and graphql
as our gateway server.
Recently, we received a vulnerability report that:
We have to upgrade the gqlparser
version for security reason, but after we upgrade the version, the nautilus gateway cannot startup correctly, it reports a failure during the startup:
while gateway setup: while creating gateway: conflict in argument definitions for directive defer: one is a list the other isn't
After the investigation, I found the reason is gqlparser
add a new directive defer in its inner schema after release v2.5.2
(But nautilus graphql is still using the v2.0.1:
https://github.com/vektah/gqlparser/blob/v2.5.2/validator/prelude.graphql#L31
directive @defer(if: Boolean = true, label: String) on FRAGMENT_SPREAD | INLINE_FRAGMENT
After adding this directive @defer
and with the default Boolean value true
, the graphql introspection cannot match its default value because it doesn't support to set the default value for the argument of directive:
https://github.com/nautilus/graphql/blob/master/introspection.go#L340-L344
So the failure will happen during the multiple schema merge:
https://github.com/nautilus/gateway/blob/master/merge.go#L607-L609
So I prepared a workaround to add default value if it exists, it works fine for me, but I think it is not an official fix:
zhangtbj@c0d6961
I am not sure if it can be fixed by nautilus graphql community officially or do you have any other good idea?
I am not sure who can help here, so cc @JohnStarich for help too.
Thanks a lot!
Introspecting the following schema results in an invalid AST:
{
"__schema": {
"queryType": {
"name": "Query"
},
"types": [
{
"description": null,
"enumValues": [],
"fields": [
{
"args": [
{
"defaultValue": null,
"description": null,
"name": "id",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
],
"deprecationReason": null,
"description": "Find a Node for the given ID. Use fragments to select additional fields.",
"isDeprecated": false,
"name": "node",
"type": {
"kind": "INTERFACE",
"name": "Node",
"ofType": null
}
}
],
"inputFields": [],
"interfaces": [],
"kind": "OBJECT",
"name": "Query",
"possibleTypes": []
},
{
"description": "A resource.",
"enumValues": [],
"fields": [
{
"args": [],
"deprecationReason": null,
"description": "The ID of this resource.",
"isDeprecated": false,
"name": "id",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
],
"inputFields": [],
"interfaces": [
{
"kind": "INTERFACE",
"name": "Node",
"ofType": null
}
],
"kind": "OBJECT",
"name": "Resource",
"possibleTypes": []
},
{
"description": "Fetches an object given its ID.",
"enumValues": [],
"fields": [
{
"args": [],
"deprecationReason": null,
"description": "The globally unique object ID.",
"isDeprecated": false,
"name": "id",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
}
}
],
"inputFields": [],
"interfaces": [],
"kind": "INTERFACE",
"name": "Node",
"possibleTypes": [
{
"kind": "INTERFACE",
"name": "Node",
"ofType": null
},
{
"kind": "OBJECT",
"name": "Resource",
"ofType": null
}
]
}
]
}
}
This outputs an AST with the ast.Definition.Types
field populated for non-Unions. The gqlparser formatter doesn't handle this well, since it assumes the AST is produced by gqlparser and already valid, whereas Introspect assembles its own AST.
The formatted schema looks like this today:
"""
Fetches an object given its ID.
"""
interface Node = Resource {
"""
The globally unique object ID.
"""
id: ID!
}
type Query {
"""
Find a Node for the given ID. Use fragments to select additional fields.
"""
node(id: ID!): Node
}
"""
A resource.
"""
type Resource implements Node {
"""
The ID of this resource.
"""
id: ID!
}
When it should look like this (no = Resource
):
"""
Fetches an object given its ID.
"""
interface Node {
"""
The globally unique object ID.
"""
id: ID!
}
type Query {
"""
Find a Node for the given ID. Use fragments to select additional fields.
"""
node(id: ID!): Node
}
"""
A resource.
"""
type Resource implements Node {
"""
The ID of this resource.
"""
id: ID!
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.