shopify-graphql

command module
v0.0.0-...-b949ca1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

README

shopify-graphql

Motivation

I want to reverse engineer the shopify graphql API.

What is the approach

Using this:

query IntrospectionQuery {
  __schema {
    queryType {
      name
    }
    mutationType {
      name
    }
    subscriptionType {
      name
    }
    types {
      ...FullType
    }
    directives {
      name
      description
      locations
      args {
        ...InputValue
      }
    }
  }
}

fragment FullType on __Type {
  kind
  name
  description
  fields(includeDeprecated: true) {
    name
    description
    args {
      ...InputValue
    }
    type {
      ...TypeRef
    }
    isDeprecated
    deprecationReason
  }
  inputFields {
    ...InputValue
  }
  interfaces {
    ...TypeRef
  }
  enumValues(includeDeprecated: true) {
    name
    description
    isDeprecated
    deprecationReason
  }
  possibleTypes {
    ...TypeRef
  }
}

fragment InputValue on __InputValue {
  name
  description
  type {
    ...TypeRef
  }
  defaultValue
}

fragment TypeRef on __Type {
  kind
  name
  ofType {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
}

in the graphql explorer you can extract the schema.json. Find mine here. (I have remove the unnecessary parts that are returned by the explorer).

Using graphql-introspection-json you can easily generate the sdl from it using:

graphql-introspection-json-to-sdl schema.json > schema.graphql

Last step is to generate the stubs via gqlgen.

I spent the first half hours chasing a phantom bug which I assumed in gqlgen. However you have to remove the first alleged type inside the schema.graphql. It is sth. like QueryRoot or sth... If you don't throw it you will either:

  • build the glqgen stuff yourself and debug it
  • cry

Please don't cry.

crying cat

To spare you the cry etc. and because I am a nice person I will add the generated stuff here for reference.

License

This project is licensed under the GPL-3 license.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL