forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(i): Retain embedded schema within gql types on reload (sourcenetw…
…ork#2185) ## Relevant issue(s) Resolves sourcenetwork#2184 sourcenetwork#2182 ## Description Retain embedded schema within gql types on reload and further GQL modification. Also refactors the code a little to make it harder to re-introduce (calling `loadSchema` instead of sometimes relying on function vars).
- Loading branch information
1 parent
083aea1
commit 93b3911
Showing
8 changed files
with
333 additions
and
51 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Copyright 2024 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 one_to_one | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestView_OneToOneDuplicateEmbeddedSchema_Errors(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Description: "One to one view and duplicate embedded schema", | ||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: ` | ||
type Author { | ||
name: String | ||
books: [Book] | ||
} | ||
type Book { | ||
name: String | ||
author: Author | ||
} | ||
`, | ||
}, | ||
testUtils.CreateView{ | ||
Query: ` | ||
Author { | ||
name | ||
books { | ||
name | ||
} | ||
} | ||
`, | ||
SDL: ` | ||
type AuthorView { | ||
name: String | ||
books: [BookView] | ||
} | ||
interface BookView { | ||
name: String | ||
} | ||
`, | ||
}, | ||
// Try and create a second view that creates a new `BookView`, this | ||
// should error as `BookView` has already been created by the first view. | ||
testUtils.CreateView{ | ||
Query: ` | ||
Author { | ||
authorName: name | ||
books { | ||
bookName: name | ||
} | ||
} | ||
`, | ||
SDL: ` | ||
type AuthorAliasView { | ||
authorName: String | ||
books: [BookView] | ||
} | ||
interface BookView { | ||
bookName: String | ||
} | ||
`, | ||
ExpectedError: "schema type already exists. Name: BookView", | ||
}, | ||
testUtils.IntrospectionRequest{ | ||
Request: ` | ||
query { | ||
__type (name: "BookView") { | ||
name | ||
} | ||
} | ||
`, | ||
ExpectedData: map[string]any{ | ||
"__type": map[string]any{ | ||
"name": "BookView", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
testUtils.ExecuteTestCase(t, test) | ||
} |
Oops, something went wrong.