1 module types;
2 
3 __EOF__
4 
5 import std.typecons : Flag;
6 public import taggedalgebraic;
7 
8 alias NotNull = Flag!"NotNull";
9 
10 struct GraphQLType {
11 	NotNull notNull;
12 	string description;
13 
14 	this(Args...)(auto ref Args args) {
15 		foreach(ref arg; args) {
16 			static if(is(typeof(arg) == NotNull)) {
17 				this.notNull = arg;
18 			}
19 		}
20 	}
21 }
22 
23 template GQLImplements(T) {
24 	enum GQLImplements = "";
25 }
26 
27 unittest {
28 	import std.container.array;
29 
30 	static struct Bar {
31 
32 	}
33 
34 	static struct Foo {
35 		@GraphQLType(NotNull.yes) long id;
36 		@GraphQLType() Array!string arr;
37 		mixin(GQLImplements!Bar);
38 	}
39 
40 	Foo foo;
41 }
42 
43 unittest {
44 	static struct Bar {
45 		int a;
46 	}
47 
48 	static struct Foo {
49 		string a;
50 	}
51 
52 	static union Foobar {
53 		Bar bar;
54 		Foo foo;
55 	}
56 
57 	alias Foos = TaggedAlgebraic!Foobar;
58 
59 	Foos foo;
60 	foo = Foo("10");
61 }
62 
63 unittest {
64 	import lexer;
65 	import parser;
66 	import std.experimental.allocator;
67 	import std.experimental.allocator.mallocator : Mallocator;
68 	import std.stdio : writeln;
69 
70 	string s = `{
71   __schema {
72     queryType {
73       name
74     }
75   }
76 }`;
77 	auto l = Lexer(s);
78 	auto p = Parser(l);
79 	try {
80 		auto d = p.parseDocument();
81 	} catch(Throwable e) {
82 		writeln(e.toString());
83 		while(e.next) {
84 			writeln(e.next.toString());
85 			e = e.next;
86 		}
87 		assert(false);
88 	}
89 	assert(p.lex.empty);
90 }