Skip to content

Commit

Permalink
Add more capabilities to control how the connection name is created. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Aug 18, 2021
1 parent 38e50c8 commit 15da3b0
Show file tree
Hide file tree
Showing 188 changed files with 4,175 additions and 2,978 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@
interface Character {
id: ID!
name: String!
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): CharacterConnection
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
appearsIn: [Episode]
height(unit: Unit): Float
}

type Droid implements Character {
id: ID!
name: String!
appearsIn: [Episode]
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
height(unit: Unit): Float
primaryFunction: String
}

"A connection to a list of items."
type CharacterConnection {
type FriendsConnection {
"Information to aid in pagination."
pageInfo: PageInfo!
"A list of edges."
edges: [CharacterEdge!]
edges: [FriendsEdge!]
"A flattened list of the nodes."
nodes: [Character]
}

"An edge in a connection."
type CharacterEdge {
type FriendsEdge {
"A cursor for use in pagination."
cursor: String!
"The item at the end of the edge."
node: Character
}

type Droid implements Character {
id: ID!
name: String!
appearsIn: [Episode]
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): CharacterConnection
height(unit: Unit): Float
primaryFunction: String
}

type Human implements Character {
id: ID!
name: String!
appearsIn: [Episode]
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): CharacterConnection
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
otherHuman: Human
height(unit: Unit): Float
homePlanet: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using HotChocolate.Execution.Processing;
using HotChocolate.Language;
using HotChocolate.StarWars;
using HotChocolate.Types;

namespace HotChocolate.Execution.Benchmarks
{
[RPlotExporter, CategoriesColumn, RankColumn, MeanColumn, MedianColumn, MemoryDiagnoser]
public class FieldCollectorBenchmarks
{
private readonly InputParser _inputParser = new();
private readonly ISchema _schema;
private readonly DocumentNode _introspectionQuery;
private readonly FragmentCollection _introspectionFragments;
Expand Down Expand Up @@ -39,7 +41,8 @@ public object PrepareSelectionSets_Introspection()
_introspectionQuery,
_introspectionOperation,
_schema,
_schema.QueryType);
_schema.QueryType,
_inputParser);
}

[Benchmark]
Expand All @@ -50,7 +53,8 @@ public object PrepareSelectionSets_StarWars()
_starWarsQuery,
_starWarsOperation,
_schema,
_schema.QueryType);
_schema.QueryType,
_inputParser);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class VariableCoercionBenchmarks

public VariableCoercionBenchmarks()
{
_variableCoercionHelper = new VariableCoercionHelper();
_variableCoercionHelper = new VariableCoercionHelper(new(), new());
_schema = SchemaBuilder.New().AddStarWarsTypes().Create();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static int DefaultCalculation(ComplexityContext context)
}

var cost = context.Complexity + context.ChildComplexity;
bool needsDefaultMultiplier = true;
var needsDefaultMultiplier = true;

foreach (MultiplierPathString multiplier in context.Multipliers)
{
Expand All @@ -74,7 +74,7 @@ public static int DefaultCalculation(ComplexityContext context)
}
}

if(needsDefaultMultiplier && context.DefaultMultiplier.HasValue)
if(needsDefaultMultiplier && context.DefaultMultiplier.HasValue)
{
cost *= context.DefaultMultiplier.Value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,18 @@ public static IObjectFieldDescriptor UseDataloader(
definition.Type = TypeReference.Create(schemaType, TypeContext.Output);
definition.Configurations.Add(
LazyTypeConfigurationBuilder
.New<ObjectFieldDefinition>()
.Definition(definition)
.Configure(
(_, def) =>
{
CompileMiddleware(
def,
placeholder,
keyType,
valueType,
dataLoaderType);
})
.On(ApplyConfigurationOn.Completion)
.Build());
new CompleteConfiguration<ObjectFieldDefinition>(
(_, def) =>
{
CompileMiddleware(
def,
placeholder,
keyType,
valueType,
dataLoaderType);
},
definition,
ApplyConfigurationOn.Completion));
});

return descriptor;
Expand Down Expand Up @@ -111,7 +108,7 @@ private static bool TryGetDataLoaderTypes(
{
if (interfaceType.IsGenericType)
{
Type? typeDefinition = interfaceType.GetGenericTypeDefinition();
Type typeDefinition = interfaceType.GetGenericTypeDefinition();
if (typeof(IDataLoader<,>) == typeDefinition)
{
key = interfaceType.GetGenericArguments()[0];
Expand Down

This file was deleted.

Loading

0 comments on commit 15da3b0

Please sign in to comment.