Coder Social home page Coder Social logo

gqlfetch's Introduction

GQLFetch

GraphQL introspection based schema generator, introspection query document mirrors the graphql-js getIntrospectionQuery document albeit compliant to the June 2018 specification.

Usage

import (
	"github.com/suessflorian/gqlfetch"
)

func main() {
	schema, _ := gqlfetch.BuildClientSchema(ctx, endpoint)
}

Or use as cli tool

Introduced a directory here /gqlfetch which will create a gqlfetch cli tool.

go install github.com/suessflorian/gqlfetch/gqlfetch
# gqlfetch --help
gqlfetch --endpoint "localhost:8080/query" > schema.graphql

If you get an error claiming that gqlfetch cannot be found or is not defined, you may need to add ~/go/bin to your $PATH (MacOS/Linux), or %HOME%\go\bin (Windows).

Roadmap

Hoping to incorporate this into a graphql utility package like gqlparser, enable introspection based type-safe graphql client generation in genqlient and simplify the Service type federated services need to expose to a bramble gateway (improving the schema gathering logic).

Notice

Project not fully mature yet, if you find any issues, please submit an issue.

gqlfetch's People

Contributors

alwxsin avatar dekimsey avatar oatovar avatar suessflorian avatar theolind avatar ynng avatar

Stargazers

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

Watchers

 avatar  avatar

gqlfetch's Issues

Double quotes in comments cause errors

If a field comment ends with double quotes, it causes issues.

type {
"""Comment with "double quotes""""
  id: ID
}

This was automatically generated fetching a public schema.
I believe we need to use """ as proper multi-lines to make this work

Empty inputs

Hey @suessflorian, thanks for the tool.

I fetched schema and found that all inputs are empty, no fields specified

input UpdateWorkTemplateInput {
}

If I want to use schema for genqlient I need inputs, so genclient can generate proper code.

BUG, Extra square brackets

Additional square brackets

  • [WorkPartition]! -> [[[WorkPartition]!]]!
  • ID! -> [ID]!

However non-required fields are ok

error: No query string was present

Hi there,

I keep getting this error from the server and upon further inspection this happens because the query operation type is being sent as uppercase Query

{"Query":"query IntrospectionQuery {\n __schema {\n...

Server returns

{
  "errors": [
    {
      "message": "No query string was present"
    }
  ]
}

the query works fine if operation type is sent as: query

{"query":"query IntrospectionQuery {\n __schema {\n...


I'll be happy to submit a PR if needed, but it is such a minor change might just be easier for you guys to commit the change.

I couldn't find anything on wether the spec requires this to be uppercase or lowercase but from my experience I have always seen the operation types being sent lowercase. They are also shown lowercased in the spec.

Interface arguments are not generated

Description

If an interface field has arguments, they will not be generated. This causes errors when using the exported schema in genqlient.

Steps to reproduce

  1. Create a new go project
    $ mkdir sample-gengqlient-project
    $ cd sample-genqlient-project
    $ go mod init sample-genqlient-project
  2. Run go install github.com/suessflorian/gqlfetch/gqlfetch@latest
  3. Run gqlfetch --endpoint https://gitlab.com/api/graphql > schema.graphql
  4. Run go run github.com/Khan/genqlient@latest --init and observe that the it is unable to init the project because of the interface and implementation argument mismatch.

Duplicated directives in GraphQL Federation

Suppose we have a federation gateway and few GraphQL services, each of them has own graphql schema but all schemas have the same directives. In this case gqlfetch returns schema with duplicated directives.

What license is this project released under?

Description

I'm looking at using this project, but I'm unable to do so at the moment without a software license. Is the project intended to be used under a specific license?

From the GitHub docs.

You're under no obligation to choose a license. However, without a license, the default copyright laws apply, meaning that you retain all rights to your source code and no one may reproduce, distribute, or create derivative works from your work.

Combining the use of suessflorian/gqlfetch and khan/genqlient with shopify graphql api

I used gqlfetch to get the shopify graphql schema at https://%s.myshopify.com/admin/api/2023-10/graphql.json (where %s is the name of your own shopify sites graphql api).

I attached it as a gist since its huge (1.6MB of text).

https://gist.github.com/codeliger/a4f16328a928ae1b151acfeea9ff61e6

When using a khan/genqlient to generate Go code from this schema I get this error many times:

schema.graphql:548: invalid schema: For AppInstallation to implement HasMetafields any additional arguments on metafield must be optional or have a default value but key is required.

I am not sure if this is a issue related to the underlying schema or the way gqlfetch interprets it.

Built in types and directives

At this moment gqlfetch prints all types and directives fetched from a server. Problem is that build in types and directives are also printed which conflicts with genclient when I tried to generate code with error like

invalid schema file ./schema.graphql: Cannot redeclare type Float.

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.