public void PrintSchema_PrintsDeprecated() { new TestInputObjectType <Foo>("Input", this.schema) .Field("int", e => default(int?)) .IsDeprecated("because reasons"); this.root .Field("dep1", () => default(string)) .IsDeprecated(); this.root .Field("dep2", () => default(string)) .IsDeprecated(""); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } input Input { int: Int @deprecated(reason: ""because reasons"") } type Root { dep1: String @deprecated dep2: String @deprecated }", result); }
public void PrintSchema_PrintsInterface() { new TestInterfaceType <IFoo>("Foo", this.schema) .Field("str", e => default(string)); new TestObjectType <BarIFoo>("Bar", this.schema) .Field("str", () => default(string)); this.root .Field("bar", () => default(BarIFoo)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Bar implements Foo { str: String } interface Foo { str: String } type Root { bar: Bar }", result); }
public void PrintSchema_DoesntPrintSchemaOfCommonNames() { this.schema = new GraphQLSchema(); var query = new TestObjectType("Query", this.schema); query.Field("foo", () => default(string)); this.schema.Query(query); var mutation = new TestMutationType("Mutation", this.schema); mutation.Field("foo", () => default(int)); this.schema.Mutation(mutation); var subscription = new TestSubscriptionType("Subscription", this.schema); subscription.Field("foo", () => default(ID)); this.schema.Subscription(subscription); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" type Mutation { foo: Int! } type Query { foo: String } type Subscription { foo: ID! }", result); }
public void PrintSchema_PrintsStringFieldWithMultipleArgs() { this.root .Field("singleField", (int?argOne, string argTwo) => default(string)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Root { singleField(argOne: Int, argTwo: String): String }", result); }
public void PrintSchema_PrintsStringFieldWithNonNullIntArg() { this.root .Field("singleField", (int argOne) => default(string)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Root { singleField(argOne: Int!): String }", result); }
public void PrintSchema_PrintsStringFieldWithMultipleArgsLastIsDefault() { this.root .Field("singleField", (int?argOne, string argTwo, bool?argThree) => default(string)) .WithDefaultValue("argThree", false); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Root { singleField(argOne: Int, argTwo: String, argThree: Boolean = false): String }", result); }
public void PrintSchema_PrintsStringFieldWithIntArgWithDefaultNull() { this.root .Field("singleField", (int?argOne) => default(string)) .WithDefaultValue("argOne", null); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Root { singleField(argOne: Int = null): String }", result); }
public void PrintSchema_PrintsCustomScalar() { new TestCustomScalarType(this.schema); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } scalar Odd type Root { } ", result); }
public void PrintSchema_PrintsOperationDefinitions() { this.schema = new GraphQLSchema(); var query = new TestObjectType("QueryRoot", this.schema); query.Field("foo", () => default(string)); this.schema.Query(query); var mutation = new TestMutationType("MutationRoot", this.schema); mutation.Field("foo", () => default(int)); this.schema.Mutation(mutation); var subscription = new TestSubscriptionType("SubscriptionRoot", this.schema); subscription.Field("foo", () => default(ID)); this.schema.Subscription(subscription); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: QueryRoot mutation: MutationRoot subscription: SubscriptionRoot } type MutationRoot { foo: Int! } type QueryRoot { foo: String } type SubscriptionRoot { foo: ID! }", result); }
public void PrintSchema_PrintsUnions() { new TestObjectType <Foo>("Foo", this.schema) .Field("bool", () => default(bool?)); new TestObjectType <Bar>("Bar", this.schema) .Field("str", () => default(string)); this.schema .AddKnownType(new TestSingleUnionType()); this.schema .AddKnownType(new TestMultipleUnionType()); this.root .Field("single", () => default(object)).ResolveWithUnion <TestSingleUnionType>(); this.root .Field("multiple", () => default(object)).ResolveWithUnion <TestMultipleUnionType>(); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Bar { str: String } type Foo { bool: Boolean } union MultipleUnion = Foo | Bar type Root { single: SingleUnion multiple: MultipleUnion } union SingleUnion = Foo ", result); }
public void PrintSchema_PrintsObjectField() { new TestObjectType <Foo>("Foo", this.schema) .Field("str", () => default(string)); this.root .Field("foo", () => default(Foo)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } type Foo { str: String } type Root { foo: Foo }", result); }
public void PrintSchema_PrintsInputType() { new TestInputObjectType <Foo>("InputType", this.schema) .Field("int", e => default(int?)); this.root .Field("str", (Foo argOne) => default(string)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } input InputType { int: Int } type Root { str(argOne: InputType): String } ", result); }
public void PrintSchema_PrintsMultipleInterfaces() { new TestInterfaceType <IFoo>("Foo", this.schema) .Field("str", e => default(string)); new TestInterfaceType <IBaaz>("Baaz", this.schema) .Field("int", e => default(int?)); var bar = new TestObjectType <BarIFooIBaaz>("Bar", this.schema); bar.Field("str", () => default(string)); bar.Field("int", () => default(int?)); this.root.Field("bar", () => default(BarIFooIBaaz)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } interface Baaz { int: Int } type Bar implements Foo, Baaz { str: String int: Int } interface Foo { str: String } type Root { bar: Bar } ", result); }
public void PrintSchema_PrintsEnum() { new TestEnumType <RGBType>("RGB", this.schema); this.root .Field("rgb", () => default(RGBType?)); var result = SchemaUtils.PrintSchema(this.schema); this.AreEqual(@" schema { query: Root } enum RGB { RED GREEN BLUE } type Root { rgb: RGB } ", result); }
private string PrintSingleFieldSchema <T>() { this.root.Field("singleField", () => default(T)); return(SchemaUtils.PrintSchema(this.schema)); }