Skip to content

`fetch': key not found: "data" (KeyError) #60

@knassef

Description

@knassef

Hi, I am trying to do this for a shops schema, I downloaded the schema file which is 106k lines. then ran the commands you mentioned in the README. got the error below.

schema file looks like:
shopify-admin.json

{
  "__schema": {
    "queryType": {
      "name": "QueryRoot"
    },
    "mutationType": {
      "name": "Mutation"
    },
    "subscriptionType": null,
    "types": ...,
    "directives": ...,
  }
}

example.ruby

require 'graphql_schema'
require 'graphql_java_gen'
require 'json'

introspection_result = File.read("shopify-admin.json")
schema = GraphQLSchema.new(JSON.parse(introspection_result))

GraphQLJavaGen.new(schema,
  package_name: "com.example.MyApp",
  nest_under: 'ExampleSchema',
  version: '2022-01',
  custom_scalars: [
    GraphQLJavaGen::Scalar.new(
      type_name: 'Decimal',
      java_type: 'BigDecimal',
      deserialize_expr: ->(expr) { "new BigDecimal(jsonAsString(#{expr}, key))" },
      imports: ['java.math.BigDecimal'],
    ),
  ]
).save("#{Dir.pwd}/../MyApp/src/main/java/com/example/MyApp/ExampleSchema.java")

error:

khaled@khaleds-mbp graphql_java_gen-master % ruby example.ruby                                                            
Traceback (most recent call last):
	3: from example.ruby:6:in `<main>'
	2: from example.ruby:6:in `new'
	1: from /Library/Ruby/Gems/2.6.0/gems/graphql_schema-0.1.8/lib/graphql_schema.rb:6:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/graphql_schema-0.1.8/lib/graphql_schema.rb:6:in `fetch': key not found: "data" (KeyError)

versions:
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]

{
"dependencies": {
"apollo": "2.33.4",
"graphql": "^14.6.0"
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions