Code Monkey home page Code Monkey logo

graphql's Introduction

nautilus

Central repo for various odds and ends

graphql's People

Contributors

alecaivazis avatar danielvladco avatar edwinmo-splunk avatar greenmato avatar jasondeutsch avatar johnstarich avatar mfinley3 avatar obukhov avatar pkosiec avatar sgy1980de avatar svilgelm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphql's Issues

The default graphql @deprecated directive is skipped

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!]

Union / fragments handling error in 0.0.17

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!

Introspection schema returns empty values for input types

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.

Cannot use object fragment on interface: Fragment cannot be spread here as objects of type "Node" can never be of type "Foo"

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
                    }
                ]
            }
        ]
    }
}

[Question] : Do we have retry option for IntrospectAPI().

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

IntrospectAPI support authorization

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.

[discussion][enhancement] middleware for introspection call

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:

  1. if my evaluation is correct
  2. adding this capability.

If an addition is required perhaps one approach could including new-ing up an introspection request object of some sort and then calling WithMiddlewares(...)

Formatting and re-parsing IntrospectAPI's AST result fails as an invalid schema

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!
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.