-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move request model out of parser package
The parser package is now responisble for converting an gql-ast into a shared model. Soon it will be responisble for converting a string into the shared model. Mostly a copy-paste commit.
- Loading branch information
1 parent
271cf33
commit b564448
Showing
17 changed files
with
379 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package request | ||
|
||
import "github.com/sourcenetwork/defradb/client" | ||
|
||
type Aggregate struct { | ||
Field | ||
|
||
Targets []*AggregateTarget | ||
} | ||
|
||
type AggregateTarget struct { | ||
HostName string | ||
ChildName client.Option[string] | ||
|
||
Limit client.Option[uint64] | ||
Offset client.Option[uint64] | ||
OrderBy client.Option[OrderBy] | ||
Filter client.Option[Filter] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package request | ||
|
||
import "github.com/sourcenetwork/defradb/client" | ||
|
||
var ( | ||
_ Selection = (*CommitSelect)(nil) | ||
) | ||
|
||
type CommitSelect struct { | ||
Field | ||
|
||
DocKey client.Option[string] | ||
FieldName client.Option[string] | ||
Cid client.Option[string] | ||
Depth client.Option[uint64] | ||
|
||
Limit client.Option[uint64] | ||
Offset client.Option[uint64] | ||
OrderBy client.Option[OrderBy] | ||
GroupBy client.Option[GroupBy] | ||
|
||
Fields []Selection | ||
} | ||
|
||
func (c CommitSelect) ToSelect() *Select { | ||
return &Select{ | ||
Field: Field{ | ||
Name: c.Name, | ||
Alias: c.Alias, | ||
}, | ||
Limit: c.Limit, | ||
Offset: c.Offset, | ||
OrderBy: c.OrderBy, | ||
GroupBy: c.GroupBy, | ||
Fields: c.Fields, | ||
Root: CommitSelection, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package request | ||
|
||
import "github.com/sourcenetwork/defradb/client" | ||
|
||
// Field implements Selection | ||
type Field struct { | ||
Name string | ||
Alias client.Option[string] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package request | ||
|
||
// Filter contains the parsed condition map to be | ||
// run by the Filter Evaluator. | ||
// @todo: Cache filter structure for faster condition | ||
// evaluation. | ||
type Filter struct { | ||
// parsed filter conditions | ||
Conditions map[string]any | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package request | ||
|
||
import "github.com/sourcenetwork/defradb/client" | ||
|
||
type MutationType int | ||
|
||
const ( | ||
NoneMutationType = MutationType(iota) | ||
CreateObjects | ||
UpdateObjects | ||
DeleteObjects | ||
) | ||
|
||
// Mutation is a field on the MutationType | ||
// of a graphql query. It includes all the possible | ||
// arguments and all | ||
// | ||
// @todo: Change name to ObjectMutation to indicate | ||
// generated object mutation actions | ||
type Mutation struct { | ||
Field | ||
Type MutationType | ||
|
||
// Schema is the target schema/collection | ||
// if this mutation is on an object. | ||
Schema string | ||
|
||
IDs client.Option[[]string] | ||
Filter client.Option[Filter] | ||
Data string | ||
|
||
Fields []Selection | ||
} | ||
|
||
// ToSelect returns a basic Select object, with the same Name, Alias, and Fields as | ||
// the Mutation object. Used to create a Select planNode for the mutation return objects. | ||
func (m Mutation) ToSelect() *Select { | ||
return &Select{ | ||
Field: Field{ | ||
Name: m.Schema, | ||
Alias: m.Alias, | ||
}, | ||
Fields: m.Fields, | ||
DocKeys: m.IDs, | ||
Filter: m.Filter, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package request | ||
|
||
type Request struct { | ||
Queries []*OperationDefinition | ||
Mutations []*OperationDefinition | ||
} | ||
|
||
type Selection any | ||
|
||
type OperationDefinition struct { | ||
Selections []Selection | ||
IsExplain bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.