-
Notifications
You must be signed in to change notification settings - Fork 40
/
Rakefile
46 lines (41 loc) · 1.35 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require "bundler/gem_tasks"
task test: :generate do |t|
Dir.chdir('codegen') do
system('rake', 'test') || abort
end
Dir.chdir('support') do
system('./gradlew', 'check') || abort
end
end
task :generate do
require 'graphql_schema'
require 'graphql_java_gen'
require_relative 'codegen/test/support/schema'
GraphQLJavaGen.new(
GraphQLSchema.new(Support::Schema.introspection_result),
package_name: 'com.shopify.graphql.support',
nest_under: 'Generated',
version: '2020-01',
custom_scalars: [
GraphQLJavaGen::Scalar.new(
type_name: 'Time',
java_type: 'LocalDateTime',
deserialize_expr: ->(expr) { "LocalDateTime.parse(jsonAsString(#{expr}, key))" },
imports: ['java.time.LocalDateTime'],
)
],
custom_annotations: [
GraphQLJavaGen::Annotation.new(
'Nullable',
imports: ['com.shopify.graphql.support.Nullable']
) { |field| !field.type.non_null? },
]
).save('support/src/test/java/com/shopify/graphql/support/Generated.java')
GraphQLJavaGen.new(
GraphQLSchema.new(Support::Schema.introspection_result(Support::Schema::MinimalSchema)),
package_name: 'com.shopify.graphql.support',
nest_under: 'GeneratedMinimal',
version: '2020-01'
).save('support/src/test/java/com/shopify/graphql/support/GeneratedMinimal.java')
end
task :default => :test