Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
knassef opened this issue Jan 21, 2022 · 0 comments
Open

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

knassef opened this issue Jan 21, 2022 · 0 comments

Comments

@knassef
Copy link

knassef commented Jan 21, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant